angular 自定义指令
1:首先获取module对象 var myAppModule = angular.module('myApp', []);
2:定义指令 my.directive('myPlanet', [
function myPlanetDirectiveFactory() {
return {
restrict : 'E',
scope : {},
link : function($scope, $element) {
$element.text("我是自定义的指令! ');
}
}
2:定义指令 my.directive('myPlanet', [
function myPlanetDirectiveFactory() {
return {
restrict : 'E',
scope : {},
link : function($scope, $element) {
$element.text("我是自定义的指令! ');
}
}
} ]);
3:使用:
<my-planet>sdfdsf</my-planet>