angularjs“你好世界”指令+ coffeescript不工作(angularjs “hello world” directive + coffeescript not working)

编程入门 行业动态 更新时间:2024-10-17 15:29:01
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/

更多推荐

本文发布于:2023-07-16 12:54:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1128656.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:指令   你好   工作   世界   angularjs

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!