2016-04-06 21 views
1

角度バージョンの移行後に、次のような問題が発生しました。バージョン1.2.6からバージョン1.4.3に移行します。次に、angularバージョン1.2.6を使用して実装されたサンプルコードを示します。バージョン移行で角型ディレクティブとバインディング式が一致しない

角度1.2.6のバージョンで行われました。

--- --- JSP

<div> 
<span call-test config="testConfig.test1" status="getStatus" value="testValue"></span>         
</div> 
. 
. 
. 
<div>       
<span call-test config="testConfig.test2" status="getStatus" value="testValue"></span> 
</div> 

--- --- testCtrl.js

$scope.testConfig = { 
    test1 : {name: "Test1", type: 0}, 
    test2 : {name: "Test2", type: 1} 
}; 
. 
. 
. 

$scope.getStatus = function(arg){ 
switch(arg) { 
     case 1 : 

      return (validate $scope.arg and return true or false); 
     case 2 : 

      return (validate $scope.arg and return true or false); 
     case 0 : 

      return (validate $scope.arg and return true or false); 
     default : 

      return false; 
    } 
} 

--- testDirective.js ----

angular.module('com.test.directives', []) 
.directive('callTest', ['$timeout', function($timeout) { 

var callTest = function(element, scope){ 

    $timeout(function(){ 
     var statusAction = scope.status(scope.config.type);// bind value only for first span. but works fine if we pass 'scope.config'. 

    }, 100); 

}; 

return { 
     restrict: 'EA', 
     scope:{ 
      config:'=', 
      status:'&'   
}, 
     link: function(scope, element, attrs) { 
      var statusAction = scope.status(); 
      scope.$watch('value', function(){ 
       callTest(element, scope); 
      }); 

     } 
    }; 
}]); 

私は 'testDirective.js'で何か正しくないと信じています。ここで起こるのは、「ステータス」は最初のスパンのみのバインディングです。貴重なご意見やご提案をお寄せください。

答えて

0

@Navinあなたはscope ["config"]のようにチェックすることができますか?

関連する問題