File tree Expand file tree Collapse file tree 7 files changed +73
-1
lines changed Expand file tree Collapse file tree 7 files changed +73
-1
lines changed Original file line number Diff line number Diff line change 2323 padding : 8px ;
2424}
2525
26+ form {
27+ line-height : 2 ;
28+ }
29+
30+ address {
31+ font-style : normal;
32+ }
Original file line number Diff line number Diff line change 1+ ( function ( ) {
2+ 'use strict' ;
3+
4+ angular
5+ . module ( 'myApp' )
6+ . controller ( 'EditController' , EditController ) ;
7+
8+ EditController . $inject = [ 'SearchService' , '$stateParams' ] ;
9+
10+ function EditController ( SearchService , $stateParams ) {
11+ var vm = this ;
12+
13+ SearchService . fetch ( $stateParams . id , function ( response ) {
14+ vm . person = response ;
15+ } ) ;
16+ }
17+ } ) ( ) ;
Original file line number Diff line number Diff line change 1+ < form >
2+ < div >
3+ < label for ="name "> Name:</ label >
4+ < input type ="text " ng-model ="vm.person.name " id ="name ">
5+ </ div >
6+ < div >
7+ < label for ="phone "> Phone:</ label >
8+ < input type ="text " ng-model ="vm.person.phone " id ="phone ">
9+ </ div >
10+ < fieldset >
11+ < legend > Address:</ legend >
12+ < address style ="margin-left: 50px ">
13+ < input type ="text " ng-model ="vm.person.address.street "> < br />
14+ < input type ="text " ng-model ="vm.person.address.city "> ,
15+ < input type ="text " ng-model ="vm.person.address.state " size ="2 ">
16+ < input type ="text " ng-model ="vm.person.address.zip " size ="5 ">
17+ </ address >
18+ </ fieldset >
19+ </ form >
Original file line number Diff line number Diff line change 1+ ( function ( ) {
2+ 'use strict' ;
3+
4+ angular . module ( 'myApp' )
5+ . config ( stateConfig ) ;
6+
7+ stateConfig . $inject = [ '$stateProvider' ] ;
8+
9+ function stateConfig ( $stateProvider ) {
10+ $stateProvider
11+ . state ( 'edit' , {
12+ url : '/edit/:id' ,
13+ templateUrl : 'edit/edit.html' ,
14+ controller : 'EditController' ,
15+ controllerAs : 'vm'
16+ } ) ;
17+ }
18+ } ) ( ) ;
Original file line number Diff line number Diff line change 3939 < script src ="search/search.state.js "> </ script >
4040 < script src ="search/search.controller.js "> </ script >
4141 < script src ="search/search.service.js "> </ script >
42+ < script src ="edit/edit.state.js "> </ script >
43+ < script src ="edit/edit.controller.js "> </ script >
4244 < script src ="components/version/version.js "> </ script >
4345 < script src ="components/version/version-directive.js "> </ script >
4446 < script src ="components/version/interpolate-filter.js "> </ script >
Original file line number Diff line number Diff line change 1313 </ thead >
1414 < tbody >
1515 < tr ng-repeat ="person in vm.searchResults ">
16- < td > {{ person.name}}</ td >
16+ < td > < a ui-sref =" edit({id: person.id}) " > {{ person.name}}</ a > </ td >
1717 < td > {{person.phone}}</ td >
1818 < td > {{person.address.street}}< br />
1919 {{person.address.city}}, {{person.address.state}} {{person.address.zip}}
Original file line number Diff line number Diff line change 1919 } ) ;
2020 } ;
2121
22+ Search . fetch = function ( id , callback ) {
23+ Search . query ( function ( response ) {
24+ var results = response . filter ( function ( item ) {
25+ return item . id === parseInt ( id ) ;
26+ } ) ;
27+ return callback ( results [ 0 ] ) ;
28+ } ) ;
29+ } ;
30+
2231 return Search ;
2332 }
2433} ) ( ) ;
You can’t perform that action at this time.
0 commit comments