本文主要和大家分享angularJS模块化技术详解,希望能帮助到大家。
1、directive 指令
<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>2、模块化(重用)
1)按需加载、动态加载
2)封装、隔离
1、directive 指令
<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>2、模块化(重用)
1)按需加载、动态加载
2)封装、隔离
相关推荐:
AngularJS模块学习之Anchor Scroll_AngularJS










