<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中文网其他相关文章!