【问题标题】:Watch expression does not work in modal included监视表达式在包含的模式中不起作用
【发布时间】:2014-04-16 18:02:35
【问题描述】:

我只是想把 work 变成一个 modal 的 watch 表达式,它包含在一个 html 文件中。

在我的演示中,有 2 块手表:一个可以工作,另一个不能。

http://plnkr.co/edit/bNF7Yw?p=info

谢谢

【问题讨论】:

  • 我收到“导入错误 - 未找到 Plunk”

标签: angularjs modal-dialog angularjs-scope watch angularjs-ng-include


【解决方案1】:

includemodal 应该在 ModalInstanceController 的范围内,因为该模型在用于模态的模板下定义。 Updated Plunker

$scope.openAddProductModal = function ( ) {   
      var modalInstance = $modal.open({
              templateUrl: 'AddProductModalContent.html',
              controller:  function ($scope, $modalInstance, $log) {
                $scope.includemodal={search_value:''};

                $scope.$watch('includemodal.search_value', function(new_val) {
                  console.log('includemodal.search_value ' + new_val);
                });

               $scope.ok = function () {
                $modalInstance.close();
               };

              $scope.cancel = function () {
                $modalInstance.dismiss('cancel');
              };
           },
            resolve: {

            }
          });
  };

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-03-17
    • 1970-01-01
    • 1970-01-01
    • 2014-06-21
    • 1970-01-01
    • 2013-09-08
    • 2021-07-13
    • 2016-11-08
    相关资源
    最近更新 更多