2016-04-06 21 views
1

Açısal sürüm geçişinden sonra aşağıdaki sorunla ilgili açısal ve dikey yönlendirme yapıyorum. 1.2.6 sürümünden 1.4.3 sürümüne geçiyoruz. Aşağıdaki, 1.2.6 açısal ver kullanılarak uygulanan örnek koddur; Açısal 1.2.6 sürümü ileAçısal yönerge Sürüm geçişi ile bağlaç belirtmiyor

kodu bitti.

--- 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' ile doğru olmayan bir şeye inanıyorum. Burada olan, 'durum' sadece ilk yayılma için yalnızca bağlayıcıdır. Lütfen değerli düşüncelerinizi ve önerilerinizi paylaşın.

cevap

0

@Navin bunu kapsam ["config"] gibi kontrol edebilir misiniz?

İlgili konular