angularjs“你好世界”指令+ coffeescript不工作(angularjs “hello world” directive + coffeescript not working)
假设我有我的指令
@directivesModule = angular.module('myApp.directives', [])并在directive.coffee中
directivesModule.directive 'showAuthorLogin', () -> restrict: 'E' template: '<div>Hello World</div>'index.html的:
<span showAuthorLogin></span>为什么没有任何表现?
assume I have my directives in
@directivesModule = angular.module('myApp.directives', [])and in directive.coffee
directivesModule.directive 'showAuthorLogin', () -> restrict: 'E' template: '<div>Hello World</div>'index.html:
<span showAuthorLogin></span>why isn't anything showing?
最满意答案
restrict: 'E'表示该指令必须是一个元素。 因此,您可以将指令更改为restrict: 'A'或者您可以将html更改为: <showAuthorLogin></showAuthorLogin>
这是一个在JSFiddle上工作的例子: http : //jsfiddle.net/X6A7M/
restrict: 'E' means that the directive has to be an element. So you could change the directive to restrict: 'A' or you could change your html to: <showAuthorLogin></showAuthorLogin>
Here is an example of it working on JSFiddle: http://jsfiddle.net/X6A7M/
更多推荐
发布评论