<span style="font-size: 14px;"><!DOCTYPE html><html><head><meta charset="utf-8"><script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script><br> <script><br> var app = angular.module('test',[]);<br> app.controller('con1',function($scope){<br> $scope.arr = ['app','abc','beer','clear'];<br> });<br> app.directive('abc',function(){<br> alert("执行了directive") return {<br> restrict:'E',<br> template: '<input type="text" ng-model="str"/>\<br> <ul>\<br> <li ng-repeat="v in arr" ng-show="v.indexOf(str)!=-1">{{v}}</li>\<br> <ul>'<br> }<br> }) </script><br> </head><body><br> <p ng-app="test" ng-controller="con1"><br> <abc></abc><br> </p></body></html><br></span>
1)按需載入、動態載入
2)封裝、隔離
<span style="font-size: 14px;"><!DOCTYPE html><html><head><meta charset="utf-8"><script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script><br> <script><br> var app = angular.module('test',[]);<br> app.controller('con1',function($scope){<br> $scope.arr = ['app','abc','beer','clear'];<br> });<br> app.directive('abc',function(){<br> alert("执行了directive") return {<br> restrict:'E',<br> template: '<input type="text" ng-model="str"/>\<br> <ul>\<br> <li ng-repeat="v in arr" ng-show="v.indexOf(str)!=-1">{{v}}</li>\<br> <ul>'<br> }<br> }) </script><br> </head><body><br> <p ng-app="test" ng-controller="con1"><br> <abc></abc><br> </p></body></html><br></span>
1)按需載入、動態載入
2)封裝、隔離
#相關推薦:
#AngularJS模組學習之Anchor Scroll_AngularJS
#AngularJS模組管理問題的非常規處理方法_AngularJS
AngularJS、 Angular 2、Angular4的區別詳解
以上是angularJS模組化技術詳解的詳細內容。更多資訊請關注PHP中文網其他相關文章!