在这个有角度的文件:
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
> jsfiddle:http://jsfiddle.net/rnL84/
plunker在index.html中使用ng-app而不是ng-app =’directive’.
原文链接:https://www.f2er.com/angularjs/240358.html需要在ng-app中指定script.js javascript文件中定义的模块(在此示例中为named指令),以便它获取contenteditable指令:
angular.module(‘directive’,[])…
有关工作版本,请参阅this plunker.