문제

i just want to make work a watch expression into a modal , which is included in a html file .

Into my demo, there are 2 watches : one works and the other no.

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

Thank you

도움이 되었습니까?

해결책

includemodal should be under the scope of the ModalInstanceController since that model in defined under the template that is used for the modal. 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: {

            }
          });
  };
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top