From 2430f52bb97fa9d682e5f028c977c5bf94c5ec38 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Fri, 23 Mar 2012 14:03:24 -0700 Subject: chore(module): move files around in preparation for more modules --- src/directive/ngView.js | 170 ------------------------------------------------ 1 file changed, 170 deletions(-) delete mode 100644 src/directive/ngView.js (limited to 'src/directive/ngView.js') diff --git a/src/directive/ngView.js b/src/directive/ngView.js deleted file mode 100644 index 95b1546d..00000000 --- a/src/directive/ngView.js +++ /dev/null @@ -1,170 +0,0 @@ -'use strict'; - -/** - * @ngdoc directive - * @name angular.module.ng.$compileProvider.directive.ng-view - * @restrict ECA - * - * @description - * # Overview - * `ng-view` is a directive that complements the {@link angular.module.ng.$route $route} service by - * including the rendered template of the current route into the main layout (`index.html`) file. - * Every time the current route changes, the included view changes with it according to the - * configuration of the `$route` service. - * - * @scope - * @example - - - - - - - - -
- Choose: - Moby | - Moby: Ch1 | - Gatsby | - Gatsby: Ch4 | - Scarlet Letter
- -
-
- -
$location.path() = {{$location.path()}}
-
$route.current.template = {{$route.current.template}}
-
$route.current.params = {{$route.current.params}}
-
$route.current.scope.name = {{$route.current.scope.name}}
-
$routeParams = {{$routeParams}}
-
-
- - it('should load and compile correct template', function() { - element('a:contains("Moby: Ch1")').click(); - var content = element('.doc-example-live [ng-view]').text(); - expect(content).toMatch(/controller\: ChapterCntl/); - expect(content).toMatch(/Book Id\: Moby/); - expect(content).toMatch(/Chapter Id\: 1/); - - element('a:contains("Scarlet")').click(); - content = element('.doc-example-live [ng-view]').text(); - expect(content).toMatch(/controller\: BookCntl/); - expect(content).toMatch(/Book Id\: Scarlet/); - }); - -
- */ - - -/** - * @ngdoc event - * @name angular.module.ng.$compileProvider.directive.ng-view#$viewContentLoaded - * @eventOf angular.module.ng.$compileProvider.directive.ng-view - * @eventType emit on the current ng-view scope - * @description - * Emitted every time the ng-view content is reloaded. - */ -var ngViewDirective = ['$http', '$templateCache', '$route', '$anchorScroll', '$compile', - '$controller', - function($http, $templateCache, $route, $anchorScroll, $compile, - $controller) { - return { - restrict: 'ECA', - terminal: true, - link: function(scope, element, attr) { - var changeCounter = 0, - lastScope, - onloadExp = attr.onload || ''; - - scope.$on('$afterRouteChange', function(event, next, previous) { - changeCounter++; - }); - - scope.$watch(function() {return changeCounter;}, function(newChangeCounter) { - var template = $route.current && $route.current.template; - - function destroyLastScope() { - if (lastScope) { - lastScope.$destroy(); - lastScope = null; - } - } - - function clearContent() { - // ignore callback if another route change occured since - if (newChangeCounter == changeCounter) { - element.html(''); - } - destroyLastScope(); - } - - if (template) { - $http.get(template, {cache: $templateCache}).success(function(response) { - // ignore callback if another route change occured since - if (newChangeCounter == changeCounter) { - element.html(response); - destroyLastScope(); - - var link = $compile(element.contents()), - current = $route.current; - - lastScope = current.scope = scope.$new(); - if (current.controller) { - element.contents(). - data('$ngControllerController', $controller(current.controller, {$scope: lastScope})); - } - - link(lastScope); - lastScope.$emit('$viewContentLoaded'); - lastScope.$eval(onloadExp); - - // $anchorScroll might listen on event... - $anchorScroll(); - } - }).error(clearContent); - } else { - clearContent(); - } - }); - } - }; -}]; -- cgit v1.2.3