指令和变量

时间:2015-06-26 15:13:26

标签: angularjs scope angularjs-scope using-directives

我的指令中有控制器和链接,方式如下:

myapp.directive('MyDirective', function(){
    return{
        restrict: 'A',
        transclude: true,
        scope: {
          ....
        },
        controller: function($scope) {
           $scope.variable = true;

        },
        templateUrl:  './app/templates/template.html',
        link: function(scope, element, attrs){
            scope.$watch('variable ', function(){
            console.log("variable : " + scope.variable )
          });
       }
       .....

我无法在块链接中看到scope.variable。我该如何解决?

0 个答案:

没有答案