This repository was archived by the owner on Feb 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +52
-38
lines changed Expand file tree Collapse file tree 5 files changed +52
-38
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22
33// Define the `phonecatApp` module
4- var phonecatApp = angular . module ( 'phonecatApp' , [ ] ) ;
5-
6- // Define the `PhoneListController` controller on the `phonecatApp` module
7- phonecatApp . controller ( 'PhoneListController' , function PhoneListController ( $scope ) {
8- $scope . phones = [
9- {
10- name : 'Nexus S' ,
11- snippet : 'Fast just got faster with Nexus S.'
12- } , {
13- name : 'Motorola XOOM™ with Wi-Fi' ,
14- snippet : 'The Next, Next Generation tablet.'
15- } , {
16- name : 'MOTOROLA XOOM™' ,
17- snippet : 'The Next, Next Generation tablet.'
18- }
19- ] ;
20- } ) ;
4+ angular . module ( 'phonecatApp' , [ ] ) ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 77 < link rel ="stylesheet " href ="app.css " />
88 < script src ="bower_components/angular/angular.js "> </ script >
99 < script src ="app.js "> </ script >
10+ < script src ="phone-list.component.js "> </ script >
1011 </ head >
11- < body ng-controller =" PhoneListController " >
12+ < body >
1213
13- < ul >
14- < li ng-repeat ="phone in phones ">
15- < span > {{phone.name}}</ span >
16- < p > {{phone.snippet}}</ p >
17- </ li >
18- </ ul >
14+ <!-- Use a custom component to render a list of phones -->
15+ < phone-list > </ phone-list >
1916
2017 </ body >
2118</ html >
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ // Register `phoneList` component, along with its associated controller and template
4+ angular .
5+ module ( 'phonecatApp' ) .
6+ component ( 'phoneList' , {
7+ template :
8+ '<ul>' +
9+ '<li ng-repeat="phone in $ctrl.phones">' +
10+ '<span>{{phone.name}}</span>' +
11+ '<p>{{phone.snippet}}</p>' +
12+ '</li>' +
13+ '</ul>' ,
14+ controller : function PhoneListController ( ) {
15+ this . phones = [
16+ {
17+ name : 'Nexus S' ,
18+ snippet : 'Fast just got faster with Nexus S.'
19+ } , {
20+ name : 'Motorola XOOM™ with Wi-Fi' ,
21+ snippet : 'The Next, Next Generation tablet.'
22+ } , {
23+ name : 'MOTOROLA XOOM™' ,
24+ snippet : 'The Next, Next Generation tablet.'
25+ }
26+ ] ;
27+ }
28+ } ) ;
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ describe ( 'phoneList' , function ( ) {
4+
5+ // Load the module that contains the `phoneList` component before each test
6+ beforeEach ( module ( 'phonecatApp' ) ) ;
7+
8+ // Test the controller
9+ describe ( 'PhoneListController' , function ( ) {
10+
11+ it ( 'should create a `phones` model with 3 phones' , inject ( function ( $componentController ) {
12+ var ctrl = $componentController ( 'phoneList' ) ;
13+
14+ expect ( ctrl . phones . length ) . toBe ( 3 ) ;
15+ } ) ) ;
16+
17+ } ) ;
18+
19+ } ) ;
You can’t perform that action at this time.
0 commit comments