File tree Expand file tree Collapse file tree 2 files changed +19
-35
lines changed Expand file tree Collapse file tree 2 files changed +19
-35
lines changed Original file line number Diff line number Diff line change 1111 < h1 > Angular</ h1 >
1212
1313 < div ng-app ="app ">
14-
15- < input type ="text " ng-model ="model.prop1 "> < br />
16- < input type ="text " ng-model ="model.prop2 "> < br />
17- < input type ="text " ng-model ="model.prop3 ">
18-
19- < zippy attrfoo ="{{model.prop1}} " attrbar ="{{model.prop2}} "> <!-- grabs data from chrisProp -->
20- <!-- NOTE: content that is transcluded has access to parent scope.
21- This is how model.content is available to the view
22- -->
23- < p > Third input is : "{{model.prop3}}". First input is "{{model.prop1}}".</ p >
24- </ zippy >
25-
14+ < div ng-controller ="AppCtrl "> </ div >
2615 </ div >
2716
28-
2917 < script src ="js/angular.js "> </ script >
3018 < script src ="js/app.js "> </ script >
31-
32-
3319</ body >
3420</ html >
Original file line number Diff line number Diff line change 11// Define an App
22var app = angular . module ( 'app' , [ ] ) ;
33
4- app . directive ( 'zippy' , function ( ) {
5- return {
6- restrict : 'E' ,
7- transclude : true ,
8- scope : {
9- attrfoo : '@' ,
10- attrbar : '@'
11- } ,
12- templateUrl : 'templates/zippy_template.html' ,
4+ app . controller ( 'AppCtrl' , function ( $scope , $q ) {
135
14- link : function ( scope ) {
15- scope . isContentVisible = false ;
6+ var defer = $q . defer ( ) ;
167
17- scope . toggleContent = function ( ) {
18- scope . isContentVisible = ! scope . isContentVisible ;
19- console . log ( 'toggleContent Fired' ) ;
20- } ;
8+ defer . promise
9+ . then ( function ( weapon ) {
10+ alert ( 'You can have my ' + weapon ) ;
11+
12+ return 'bow' ;
13+ } )
14+ . then ( function ( weapon ) {
15+ alert ( 'And my ' + weapon ) ;
16+
17+ return 'axe' ;
18+ } )
19+ . then ( function ( weapon ) {
20+ alert ( 'As well as my ' + weapon ) ;
21+ } )
22+
23+ defer . resolve ( 'sword' ) ;
2124
22- scope . myFunc = function ( ) {
23- console . log ( 'myfunct Fired' ) ;
24- } ;
25- }
26- } ;
2725} ) ;
You can’t perform that action at this time.
0 commit comments