1
角指令可以在下面的圖形取代:與routeParams
.directive('currentStep', ['$log', function($log) {
return {
restrict: 'A',
link: function(scope, element, attrs){
$log.log("tmsstep is: " + scope.tmsstep);
return attrs.currentStep === scope.tmsstep;
}
};
}]);
要直接訪問routeParams類似(這似乎不工作):
.directive('currentStep', ['$log', '$routeParams' , function($log) {
return {
restrict: 'A',
link: function(scope, element, attrs){
$log.log("tmsstep is: " + $routeParams.tmsstep);
return attrs.currentStep === $routeParams.tmsstep;
}
};
}]);
的目的是爲了避免在$ scope和$ routeParams中都有tmsstep
你缺少了'$ routeParams'參數,以此來指導方法正確的語法。 – Chandermani
函數($ log)或函數(範圍,元素,attrs) –