forked from angular/angular-phonecat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
step-2 angular template with repeater
- Converted the static html list into dynamic one by: - creating PhoneListCtrl controller for the application - extracting the data from HTML into a the controller as an in-memory dataset - converting the static document into a template with the use of `[ngRepeat]` [directive] which iterates over the dataset with phones, clones the ngRepeat template for each instance and renders it into the view - Added a simple unit test to show off how to write tests and run them with Karma (see README.md for instructions)
- Loading branch information
1 parent
3e2495f
commit bf5fea6
Showing
3 changed files
with
29 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
'use strict'; | ||
|
||
/* Controllers */ | ||
|
||
var phonecatApp = angular.module('phonecatApp', []); | ||
|
||
phonecatApp.controller('PhoneListCtrl', function($scope) { | ||
$scope.phones = [ | ||
{'name': 'Nexus S', | ||
'snippet': 'Fast just got faster with Nexus S.'}, | ||
{'name': 'Motorola XOOM™ with Wi-Fi', | ||
'snippet': 'The Next, Next Generation tablet.'}, | ||
{'name': 'MOTOROLA XOOM™', | ||
'snippet': 'The Next, Next Generation tablet.'} | ||
]; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
'use strict'; | ||
|
||
/* jasmine specs for controllers go here */ | ||
describe('PhoneCat controllers', function() { | ||
|
||
describe('controllers', function() { | ||
describe('PhoneListCtrl', function(){ | ||
|
||
it("should do something", function() { | ||
beforeEach(module('phonecatApp')); | ||
|
||
}); | ||
it('should create "phones" model with 3 phones', inject(function($controller) { | ||
var scope = {}, | ||
ctrl = $controller('PhoneListCtrl', {$scope:scope}); | ||
|
||
expect(scope.phones.length).toBe(3); | ||
})); | ||
|
||
}); | ||
}); |