可以替换以下模式:
.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