angular 自定义指令

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

            } ]);

3:使用:

<my-planet>sdfdsf</my-planet>

posted @ 2014-02-17 11:32  小小架构师  阅读(110)  评论(0编辑  收藏  举报