AngularJS指令:我们不应该使用后缀“start”吗?

9

这是一个Bug,还是有文档说明不要在指令名称中使用后缀“start”?只有“finish”指令有效。

HTML:

<html ng-app="myApp">
...
<body>
  <h2>Angular doesn't like the suffix 'start'</h2>
  <div this-is-the-start="abc"></div>
  <div this-is-the-finish="abc"></div>
</body>
...
</html>

JS:

var myApp = angular.module('myApp',[]);

myApp.directive('thisIsTheFinish', function() {
  return {
    restrict: 'A',
    template: 'finish'
  }  
});

myApp.directive('thisIsTheStart', function() {
  return {
    restrict: 'A',
      template: 'start'
  }  
});

实际代码演示: http://plnkr.co/edit/SrNncw?p=preview


13
https://github.com/angular/angular.js/issues/3589 - calebboyd
1
哇,基本上这是“好的”了。看起来有点虚假。好知道。感谢提供链接。 - Jesse
1个回答

1
我正在发布这个答案,以便您可以标记此问题已回答。
正如@calebboyd指出的那样,这被提出为 GitHub上的一个问题,并在“ 1.2.0rc1 spooky-giraffe(2013-08-13)”的发布说明中添加了有关破坏性更改的注释后关闭。这是 Breaking Changes中$compile下的最后一点:
由于e46100f7,现有名称以“-start”或“-end”结尾的指令将停止工作。这个变化是为了实现多元素指令。最好的解决方法是重命名现有的指令,使它们不再以这些后缀结尾。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接