From 8e2675029f5ca404a7c649cc161df3ea642d941f Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Sat, 28 Apr 2012 22:45:28 -0700 Subject: chore(docs): re-skin main documentation --- docs/content/cookbook/deeplinking.ngdoc | 151 ++++++++++++++++++++------------ 1 file changed, 95 insertions(+), 56 deletions(-) (limited to 'docs/content/cookbook') diff --git a/docs/content/cookbook/deeplinking.ngdoc b/docs/content/cookbook/deeplinking.ngdoc index f242f82e..491e3b79 100644 --- a/docs/content/cookbook/deeplinking.ngdoc +++ b/docs/content/cookbook/deeplinking.ngdoc @@ -30,72 +30,111 @@ In this example we have a simple app which consist of two screens: * Welcome: url `welcome` Show the user contact information. * Settings: url `settings` Show an edit screen for user contact information. - -The two partials are defined in the following URLs: - -* ./examples/settings.html -* ./examples/welcome.html - - - - + + + angular.module('deepLinking', ['ngSanitize']) + .config(function($routeProvider) { + $routeProvider. + when("/welcome", {template:'welcome.html', controller:WelcomeCntl}). + when("/settings", {template:'settings.html', controller:SettingsCntl}); + }); + + AppCntl.$inject = ['$scope', '$route'] + function AppCntl($scope, $route) { + $scope.$route = $route; + + // initialize the model to something useful + $scope.person = { + name:'anonymous', + contacts:[{type:'email', url:'anonymous@example.com'}] + }; + } + + function WelcomeCntl($scope) { + $scope.greet = function() { + alert("Hello " + $scope.person.name); + }; + } + + function SettingsCntl($scope, $location) { + $scope.cancel = function() { + $scope.form = angular.copy($scope.person); + }; + + $scope.save = function() { + angular.copy($scope.form, $scope.person); + $location.path('/welcome'); + }; + + $scope.cancel(); + } + + + [ng-view] { + border: 1px solid blue; + margin: 0; + padding:1em; + } + + .partial-info { + background-color: blue; + color: white; + padding: 3px; + } + + Your App Chrome [ Welcome | Settings ] - + Partial: {{$route.current.template}} - + Your app footer - - + + + Name: + + + + + url + email + phone + + + [ X ] + + + [ add ] + + + Cancel + Save + + + Hello {{person.name}}, + + Your contact information: + {{contact.type}}: + + + + + it('should navigate to URL', function() { - element('a:contains(Welcome)').click(); - expect(element('ng\\:view').text()).toMatch(/Hello anonymous/); - element('a:contains(Settings)').click(); - input('form.name').enter('yourname'); - element(':button:contains(Save)').click(); - element('a:contains(Welcome)').click(); - expect(element('ng\\:view').text()).toMatch(/Hello yourname/); + element('a:contains(Welcome)').click(); + expect(element('[ng-view]').text()).toMatch(/Hello anonymous/); + element('a:contains(Settings)').click(); + input('form.name').enter('yourname'); + element(':button:contains(Save)').click(); + element('a:contains(Welcome)').click(); + expect(element('[ng-view]').text()).toMatch(/Hello yourname/); }); - - + + -- cgit v1.2.3