微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么这个angularjs例子对plunker不起作用?

在这个有角度的文件http://docs.angularjs.org/guide/concepts中,有一个关于指令的例子.

Directives

A directive is a behavior or DOM transformation which is triggered by the presence of a custom attribute,element name,or a class name. A directive allows you to extend the HTML vocabulary in a declarative fashion. Following is an example which enables data-binding for the contenteditable in HTML.

它提供了两个现场演示,一个用于plunker,另一个用于jsfiddle.

> plunker:http://plnkr.co/edit/nsAUafYFA1tHPo52TWUm?p=preview
> jsfiddlehttp://jsfiddle.net/rnL84/

为什么jsfiddle运行良好,但是一个不起作用?它们具有完全相同的代码,并且控制台中没有错误.

plunker在index.html中使用ng-app而不是ng-app =’directive’.

需要在ng-app中指定script.js javascript文件中定义的模块(在此示例中为named指令),以便它获取contenteditable指令:

angular.module(‘directive’,[])…

有关工作版本,请参阅this plunker.

原文地址:https://www.jb51.cc/angularjs/240358.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐