jQuery AngularJS 模态内的掩码

jQuery mask inside AngularJS modal

我在 modal 范围之外使用 jQuery 掩码,如下所示:

$("#input").mask("(00) 00000-0000");

当我尝试在我的模态控制器中使用它时,它不起作用。

有人对此有解释吗?

控制器代码:

$scope.modal = function (cl) {
    ModalService.showModal({
        templateUrl: 'modal.html',
        inputs: {
            x: x
        },
        controller: function ($scope, close, x) {

            $("#input2").mask("(00) 00000-0000");

            $scope.close = function (op) {
                //doSomething...
            };
        },
        controllerAs: "ModalController"
    }).then(function (modal) {
        modal.element.modal();
        modal.close.then(function (result) {
            //doSomething...
        });
    });
};  

考虑使用 UI-MASK

angular.module("app",['ui.mask'])
<script src="//unpkg.com/angular/angular.js"></script>
<script src="//unpkg.com/angular-ui-mask/dist/mask.js"></script>
  <body ng-app="app">
    <input type="text" ng-model="phonenumber"
           ui-mask="(99) 99999-9999"  ui-mask-placeholder 
           ui-mask-placeholder-char="_" />
    <br>
    Number= {{phonenumber}}
  </body>