码迷,mamicode.com
首页 > Web开发 > 详细

AngularJS 双向作用域

时间:2015-09-28 09:54:35      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:

双向数据绑定

1.AngularJS => DOM

技术分享
 1 <!doctype html>
 2 <html ng-app="myApp">
 3 <head>
 4   <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.js"></script>
 5 </head>
 6 <body>
 7 
 8   <label>Their URL field:</label>
 9   <input type="text" ng-model="theirUrl">
10   <div my-directive
11        some-attr="theirUrl"
12        my-link-text="Click me to go to Google"></div>
13 
14   <script>
15     angular.module(‘myApp‘, [])
16     .directive(‘myDirective‘, function() {
17       return {
18         restrict: ‘A‘,
19         replace: true,
20         scope: {
21           myUrl: ‘=someAttr‘,
22           myLinkText: ‘@‘
23         },
24         template: ‘25           <div>26             <label>My Url Field:</label>27             <input type="text" ng-model="myUrl" />28             <a href="{{myUrl}}">{{myLinkText}}</a>29           </div>3031       }
32     })
33   </script>
34 
35 </body>
36 </html>
View Code

2.DOM => AngularJS =>DOM
技术分享

 

AngularJS 双向作用域

标签:

原文地址:http://www.cnblogs.com/ByronWu12345/p/4843310.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!