No more DOM manipulation by hand!*
* - Unless we want it explicitly
<!doctype html><html lang="en" ng-app="myApp"><head><meta charset="utf-8"><title>My AngularJS App</title><link rel="stylesheet" href="css/app.css"/></head><body><ul class="menu"><li><a href="#/view1">view1</a></li><li><a href="#/view2">view2</a></li></ul><div ng-view></div><script src="lib/angular/angular.js"></script><script src="lib/angular/angular-route.js"></script><script src="js/app.js"></script><script src="js/controllers.js"></script></body></html>
'use strict';angular.module('myApp', ['ngRoute','myApp.controllers']).config(['$routeProvider', function($routeProvider) {$routeProvider.when('/view1', {templateUrl: 'partials/partial1.html',controller: 'MyCtrl1'}).when('/view2', {templateUrl: 'partials/partial2.html',controller: 'MyCtrl2'}).otherwise({redirectTo: '/view1'});}]);
'use strict';angular.module('myApp.controllers', [])
.controller('MyCtrl1', [function() {}]).controller('MyCtrl2', [function($scope) {$scope.messages = [{from: 'batman', body: 'nana nana nana nana batman!'},{from: 'joker', body: 'why so serious?'}];
}]);
<p>This is the partial for view 1.</p>
<p ng-repeat="message in messages">
{{ message.from }}: {{ message.body }}</p>
'use strict';
angular.module('myApp.filters', []).filter('strlen', [function() {return function(text) {return String(text).length;}}]);
<p ng-repeat="message in messages">{{ message.from }}:[ {{ message.body | strlen }} characters]</p>
'use strict';describe('filter', function() {beforeEach(module('myApp.filters'));describe('strlen', function() {it('should get string length',inject(function(strlenFilter) {
expect(strlenFilter('nana')).toEqual(4);}));});});
'use strict';describe('my app', function() {
browser.get('index.html');it('should automatically redirect to /view1 when location hash/fragment is empty', function() {
expect(browser.getLocationAbsUrl()).toMatch("/view1");});describe('view1', function() {beforeEach(function() {browser.get('index.html#/view1');});it('should render view1 when user navigates to /view1',
function() {expect(element.all(by.css('[ng-view] p')).first().getText()).toMatch(/partial for view 1/);});});