angular-route.js 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266
  1. /**
  2. * @license AngularJS v1.8.2
  3. * (c) 2010-2020 Google LLC. http://angularjs.org
  4. * License: MIT
  5. */
  6. (function(window, angular) {'use strict';
  7. /* global shallowCopy: true */
  8. /**
  9. * Creates a shallow copy of an object, an array or a primitive.
  10. *
  11. * Assumes that there are no proto properties for objects.
  12. */
  13. function shallowCopy(src, dst) {
  14. if (isArray(src)) {
  15. dst = dst || [];
  16. for (var i = 0, ii = src.length; i < ii; i++) {
  17. dst[i] = src[i];
  18. }
  19. } else if (isObject(src)) {
  20. dst = dst || {};
  21. for (var key in src) {
  22. if (!(key.charAt(0) === '$' && key.charAt(1) === '$')) {
  23. dst[key] = src[key];
  24. }
  25. }
  26. }
  27. return dst || src;
  28. }
  29. /* global routeToRegExp: true */
  30. /**
  31. * @param {string} path - The path to parse. (It is assumed to have query and hash stripped off.)
  32. * @param {Object} opts - Options.
  33. * @return {Object} - An object containing an array of path parameter names (`keys`) and a regular
  34. * expression (`regexp`) that can be used to identify a matching URL and extract the path
  35. * parameter values.
  36. *
  37. * @description
  38. * Parses the given path, extracting path parameter names and a regular expression to match URLs.
  39. *
  40. * Originally inspired by `pathRexp` in `visionmedia/express/lib/utils.js`.
  41. */
  42. function routeToRegExp(path, opts) {
  43. var keys = [];
  44. var pattern = path
  45. .replace(/([().])/g, '\\$1')
  46. .replace(/(\/)?:(\w+)(\*\?|[?*])?/g, function(_, slash, key, option) {
  47. var optional = option === '?' || option === '*?';
  48. var star = option === '*' || option === '*?';
  49. keys.push({name: key, optional: optional});
  50. slash = slash || '';
  51. return (
  52. (optional ? '(?:' + slash : slash + '(?:') +
  53. (star ? '(.+?)' : '([^/]+)') +
  54. (optional ? '?)?' : ')')
  55. );
  56. })
  57. .replace(/([/$*])/g, '\\$1');
  58. if (opts.ignoreTrailingSlashes) {
  59. pattern = pattern.replace(/\/+$/, '') + '/*';
  60. }
  61. return {
  62. keys: keys,
  63. regexp: new RegExp(
  64. '^' + pattern + '(?:[?#]|$)',
  65. opts.caseInsensitiveMatch ? 'i' : ''
  66. )
  67. };
  68. }
  69. /* global routeToRegExp: false */
  70. /* global shallowCopy: false */
  71. // `isArray` and `isObject` are necessary for `shallowCopy()` (included via `src/shallowCopy.js`).
  72. // They are initialized inside the `$RouteProvider`, to ensure `window.angular` is available.
  73. var isArray;
  74. var isObject;
  75. var isDefined;
  76. var noop;
  77. /**
  78. * @ngdoc module
  79. * @name ngRoute
  80. * @description
  81. *
  82. * The `ngRoute` module provides routing and deeplinking services and directives for AngularJS apps.
  83. *
  84. * ## Example
  85. * See {@link ngRoute.$route#examples $route} for an example of configuring and using `ngRoute`.
  86. *
  87. */
  88. /* global -ngRouteModule */
  89. var ngRouteModule = angular.
  90. module('ngRoute', []).
  91. info({ angularVersion: '1.8.2' }).
  92. provider('$route', $RouteProvider).
  93. // Ensure `$route` will be instantiated in time to capture the initial `$locationChangeSuccess`
  94. // event (unless explicitly disabled). This is necessary in case `ngView` is included in an
  95. // asynchronously loaded template.
  96. run(instantiateRoute);
  97. var $routeMinErr = angular.$$minErr('ngRoute');
  98. var isEagerInstantiationEnabled;
  99. /**
  100. * @ngdoc provider
  101. * @name $routeProvider
  102. * @this
  103. *
  104. * @description
  105. *
  106. * Used for configuring routes.
  107. *
  108. * ## Example
  109. * See {@link ngRoute.$route#examples $route} for an example of configuring and using `ngRoute`.
  110. *
  111. * ## Dependencies
  112. * Requires the {@link ngRoute `ngRoute`} module to be installed.
  113. */
  114. function $RouteProvider() {
  115. isArray = angular.isArray;
  116. isObject = angular.isObject;
  117. isDefined = angular.isDefined;
  118. noop = angular.noop;
  119. function inherit(parent, extra) {
  120. return angular.extend(Object.create(parent), extra);
  121. }
  122. var routes = {};
  123. /**
  124. * @ngdoc method
  125. * @name $routeProvider#when
  126. *
  127. * @param {string} path Route path (matched against `$location.path`). If `$location.path`
  128. * contains redundant trailing slash or is missing one, the route will still match and the
  129. * `$location.path` will be updated to add or drop the trailing slash to exactly match the
  130. * route definition.
  131. *
  132. * * `path` can contain named groups starting with a colon: e.g. `:name`. All characters up
  133. * to the next slash are matched and stored in `$routeParams` under the given `name`
  134. * when the route matches.
  135. * * `path` can contain named groups starting with a colon and ending with a star:
  136. * e.g.`:name*`. All characters are eagerly stored in `$routeParams` under the given `name`
  137. * when the route matches.
  138. * * `path` can contain optional named groups with a question mark: e.g.`:name?`.
  139. *
  140. * For example, routes like `/color/:color/largecode/:largecode*\/edit` will match
  141. * `/color/brown/largecode/code/with/slashes/edit` and extract:
  142. *
  143. * * `color: brown`
  144. * * `largecode: code/with/slashes`.
  145. *
  146. *
  147. * @param {Object} route Mapping information to be assigned to `$route.current` on route
  148. * match.
  149. *
  150. * Object properties:
  151. *
  152. * - `controller` – `{(string|Function)=}` – Controller fn that should be associated with
  153. * newly created scope or the name of a {@link angular.Module#controller registered
  154. * controller} if passed as a string.
  155. * - `controllerAs` – `{string=}` – An identifier name for a reference to the controller.
  156. * If present, the controller will be published to scope under the `controllerAs` name.
  157. * - `template` – `{(string|Function)=}` – html template as a string or a function that
  158. * returns an html template as a string which should be used by {@link
  159. * ngRoute.directive:ngView ngView} or {@link ng.directive:ngInclude ngInclude} directives.
  160. * This property takes precedence over `templateUrl`.
  161. *
  162. * If `template` is a function, it will be called with the following parameters:
  163. *
  164. * - `{Array.<Object>}` - route parameters extracted from the current
  165. * `$location.path()` by applying the current route
  166. *
  167. * One of `template` or `templateUrl` is required.
  168. *
  169. * - `templateUrl` – `{(string|Function)=}` – path or function that returns a path to an html
  170. * template that should be used by {@link ngRoute.directive:ngView ngView}.
  171. *
  172. * If `templateUrl` is a function, it will be called with the following parameters:
  173. *
  174. * - `{Array.<Object>}` - route parameters extracted from the current
  175. * `$location.path()` by applying the current route
  176. *
  177. * One of `templateUrl` or `template` is required.
  178. *
  179. * - `resolve` - `{Object.<string, Function>=}` - An optional map of dependencies which should
  180. * be injected into the controller. If any of these dependencies are promises, the router
  181. * will wait for them all to be resolved or one to be rejected before the controller is
  182. * instantiated.
  183. * If all the promises are resolved successfully, the values of the resolved promises are
  184. * injected and {@link ngRoute.$route#$routeChangeSuccess $routeChangeSuccess} event is
  185. * fired. If any of the promises are rejected the
  186. * {@link ngRoute.$route#$routeChangeError $routeChangeError} event is fired.
  187. * For easier access to the resolved dependencies from the template, the `resolve` map will
  188. * be available on the scope of the route, under `$resolve` (by default) or a custom name
  189. * specified by the `resolveAs` property (see below). This can be particularly useful, when
  190. * working with {@link angular.Module#component components} as route templates.<br />
  191. * <div class="alert alert-warning">
  192. * **Note:** If your scope already contains a property with this name, it will be hidden
  193. * or overwritten. Make sure, you specify an appropriate name for this property, that
  194. * does not collide with other properties on the scope.
  195. * </div>
  196. * The map object is:
  197. *
  198. * - `key` – `{string}`: a name of a dependency to be injected into the controller.
  199. * - `factory` - `{string|Function}`: If `string` then it is an alias for a service.
  200. * Otherwise if function, then it is {@link auto.$injector#invoke injected}
  201. * and the return value is treated as the dependency. If the result is a promise, it is
  202. * resolved before its value is injected into the controller. Be aware that
  203. * `ngRoute.$routeParams` will still refer to the previous route within these resolve
  204. * functions. Use `$route.current.params` to access the new route parameters, instead.
  205. *
  206. * - `resolveAs` - `{string=}` - The name under which the `resolve` map will be available on
  207. * the scope of the route. If omitted, defaults to `$resolve`.
  208. *
  209. * - `redirectTo` – `{(string|Function)=}` – value to update
  210. * {@link ng.$location $location} path with and trigger route redirection.
  211. *
  212. * If `redirectTo` is a function, it will be called with the following parameters:
  213. *
  214. * - `{Object.<string>}` - route parameters extracted from the current
  215. * `$location.path()` by applying the current route templateUrl.
  216. * - `{string}` - current `$location.path()`
  217. * - `{Object}` - current `$location.search()`
  218. *
  219. * The custom `redirectTo` function is expected to return a string which will be used
  220. * to update `$location.url()`. If the function throws an error, no further processing will
  221. * take place and the {@link ngRoute.$route#$routeChangeError $routeChangeError} event will
  222. * be fired.
  223. *
  224. * Routes that specify `redirectTo` will not have their controllers, template functions
  225. * or resolves called, the `$location` will be changed to the redirect url and route
  226. * processing will stop. The exception to this is if the `redirectTo` is a function that
  227. * returns `undefined`. In this case the route transition occurs as though there was no
  228. * redirection.
  229. *
  230. * - `resolveRedirectTo` – `{Function=}` – a function that will (eventually) return the value
  231. * to update {@link ng.$location $location} URL with and trigger route redirection. In
  232. * contrast to `redirectTo`, dependencies can be injected into `resolveRedirectTo` and the
  233. * return value can be either a string or a promise that will be resolved to a string.
  234. *
  235. * Similar to `redirectTo`, if the return value is `undefined` (or a promise that gets
  236. * resolved to `undefined`), no redirection takes place and the route transition occurs as
  237. * though there was no redirection.
  238. *
  239. * If the function throws an error or the returned promise gets rejected, no further
  240. * processing will take place and the
  241. * {@link ngRoute.$route#$routeChangeError $routeChangeError} event will be fired.
  242. *
  243. * `redirectTo` takes precedence over `resolveRedirectTo`, so specifying both on the same
  244. * route definition, will cause the latter to be ignored.
  245. *
  246. * - `[reloadOnUrl=true]` - `{boolean=}` - reload route when any part of the URL changes
  247. * (including the path) even if the new URL maps to the same route.
  248. *
  249. * If the option is set to `false` and the URL in the browser changes, but the new URL maps
  250. * to the same route, then a `$routeUpdate` event is broadcasted on the root scope (without
  251. * reloading the route).
  252. *
  253. * - `[reloadOnSearch=true]` - `{boolean=}` - reload route when only `$location.search()`
  254. * or `$location.hash()` changes.
  255. *
  256. * If the option is set to `false` and the URL in the browser changes, then a `$routeUpdate`
  257. * event is broadcasted on the root scope (without reloading the route).
  258. *
  259. * <div class="alert alert-warning">
  260. * **Note:** This option has no effect if `reloadOnUrl` is set to `false`.
  261. * </div>
  262. *
  263. * - `[caseInsensitiveMatch=false]` - `{boolean=}` - match routes without being case sensitive
  264. *
  265. * If the option is set to `true`, then the particular route can be matched without being
  266. * case sensitive
  267. *
  268. * @returns {Object} self
  269. *
  270. * @description
  271. * Adds a new route definition to the `$route` service.
  272. */
  273. this.when = function(path, route) {
  274. //copy original route object to preserve params inherited from proto chain
  275. var routeCopy = shallowCopy(route);
  276. if (angular.isUndefined(routeCopy.reloadOnUrl)) {
  277. routeCopy.reloadOnUrl = true;
  278. }
  279. if (angular.isUndefined(routeCopy.reloadOnSearch)) {
  280. routeCopy.reloadOnSearch = true;
  281. }
  282. if (angular.isUndefined(routeCopy.caseInsensitiveMatch)) {
  283. routeCopy.caseInsensitiveMatch = this.caseInsensitiveMatch;
  284. }
  285. routes[path] = angular.extend(
  286. routeCopy,
  287. {originalPath: path},
  288. path && routeToRegExp(path, routeCopy)
  289. );
  290. // create redirection for trailing slashes
  291. if (path) {
  292. var redirectPath = (path[path.length - 1] === '/')
  293. ? path.substr(0, path.length - 1)
  294. : path + '/';
  295. routes[redirectPath] = angular.extend(
  296. {originalPath: path, redirectTo: path},
  297. routeToRegExp(redirectPath, routeCopy)
  298. );
  299. }
  300. return this;
  301. };
  302. /**
  303. * @ngdoc property
  304. * @name $routeProvider#caseInsensitiveMatch
  305. * @description
  306. *
  307. * A boolean property indicating if routes defined
  308. * using this provider should be matched using a case insensitive
  309. * algorithm. Defaults to `false`.
  310. */
  311. this.caseInsensitiveMatch = false;
  312. /**
  313. * @ngdoc method
  314. * @name $routeProvider#otherwise
  315. *
  316. * @description
  317. * Sets route definition that will be used on route change when no other route definition
  318. * is matched.
  319. *
  320. * @param {Object|string} params Mapping information to be assigned to `$route.current`.
  321. * If called with a string, the value maps to `redirectTo`.
  322. * @returns {Object} self
  323. */
  324. this.otherwise = function(params) {
  325. if (typeof params === 'string') {
  326. params = {redirectTo: params};
  327. }
  328. this.when(null, params);
  329. return this;
  330. };
  331. /**
  332. * @ngdoc method
  333. * @name $routeProvider#eagerInstantiationEnabled
  334. * @kind function
  335. *
  336. * @description
  337. * Call this method as a setter to enable/disable eager instantiation of the
  338. * {@link ngRoute.$route $route} service upon application bootstrap. You can also call it as a
  339. * getter (i.e. without any arguments) to get the current value of the
  340. * `eagerInstantiationEnabled` flag.
  341. *
  342. * Instantiating `$route` early is necessary for capturing the initial
  343. * {@link ng.$location#$locationChangeStart $locationChangeStart} event and navigating to the
  344. * appropriate route. Usually, `$route` is instantiated in time by the
  345. * {@link ngRoute.ngView ngView} directive. Yet, in cases where `ngView` is included in an
  346. * asynchronously loaded template (e.g. in another directive's template), the directive factory
  347. * might not be called soon enough for `$route` to be instantiated _before_ the initial
  348. * `$locationChangeSuccess` event is fired. Eager instantiation ensures that `$route` is always
  349. * instantiated in time, regardless of when `ngView` will be loaded.
  350. *
  351. * The default value is true.
  352. *
  353. * **Note**:<br />
  354. * You may want to disable the default behavior when unit-testing modules that depend on
  355. * `ngRoute`, in order to avoid an unexpected request for the default route's template.
  356. *
  357. * @param {boolean=} enabled - If provided, update the internal `eagerInstantiationEnabled` flag.
  358. *
  359. * @returns {*} The current value of the `eagerInstantiationEnabled` flag if used as a getter or
  360. * itself (for chaining) if used as a setter.
  361. */
  362. isEagerInstantiationEnabled = true;
  363. this.eagerInstantiationEnabled = function eagerInstantiationEnabled(enabled) {
  364. if (isDefined(enabled)) {
  365. isEagerInstantiationEnabled = enabled;
  366. return this;
  367. }
  368. return isEagerInstantiationEnabled;
  369. };
  370. this.$get = ['$rootScope',
  371. '$location',
  372. '$routeParams',
  373. '$q',
  374. '$injector',
  375. '$templateRequest',
  376. '$sce',
  377. '$browser',
  378. function($rootScope, $location, $routeParams, $q, $injector, $templateRequest, $sce, $browser) {
  379. /**
  380. * @ngdoc service
  381. * @name $route
  382. * @requires $location
  383. * @requires $routeParams
  384. *
  385. * @property {Object} current Reference to the current route definition.
  386. * The route definition contains:
  387. *
  388. * - `controller`: The controller constructor as defined in the route definition.
  389. * - `locals`: A map of locals which is used by {@link ng.$controller $controller} service for
  390. * controller instantiation. The `locals` contain
  391. * the resolved values of the `resolve` map. Additionally the `locals` also contain:
  392. *
  393. * - `$scope` - The current route scope.
  394. * - `$template` - The current route template HTML.
  395. *
  396. * The `locals` will be assigned to the route scope's `$resolve` property. You can override
  397. * the property name, using `resolveAs` in the route definition. See
  398. * {@link ngRoute.$routeProvider $routeProvider} for more info.
  399. *
  400. * @property {Object} routes Object with all route configuration Objects as its properties.
  401. *
  402. * @description
  403. * `$route` is used for deep-linking URLs to controllers and views (HTML partials).
  404. * It watches `$location.url()` and tries to map the path to an existing route definition.
  405. *
  406. * Requires the {@link ngRoute `ngRoute`} module to be installed.
  407. *
  408. * You can define routes through {@link ngRoute.$routeProvider $routeProvider}'s API.
  409. *
  410. * The `$route` service is typically used in conjunction with the
  411. * {@link ngRoute.directive:ngView `ngView`} directive and the
  412. * {@link ngRoute.$routeParams `$routeParams`} service.
  413. *
  414. * @example
  415. * This example shows how changing the URL hash causes the `$route` to match a route against the
  416. * URL, and the `ngView` pulls in the partial.
  417. *
  418. * <example name="$route-service" module="ngRouteExample"
  419. * deps="angular-route.js" fixBase="true">
  420. * <file name="index.html">
  421. * <div ng-controller="MainController">
  422. * Choose:
  423. * <a href="Book/Moby">Moby</a> |
  424. * <a href="Book/Moby/ch/1">Moby: Ch1</a> |
  425. * <a href="Book/Gatsby">Gatsby</a> |
  426. * <a href="Book/Gatsby/ch/4?key=value">Gatsby: Ch4</a> |
  427. * <a href="Book/Scarlet">Scarlet Letter</a><br/>
  428. *
  429. * <div ng-view></div>
  430. *
  431. * <hr />
  432. *
  433. * <pre>$location.path() = {{$location.path()}}</pre>
  434. * <pre>$route.current.templateUrl = {{$route.current.templateUrl}}</pre>
  435. * <pre>$route.current.params = {{$route.current.params}}</pre>
  436. * <pre>$route.current.scope.name = {{$route.current.scope.name}}</pre>
  437. * <pre>$routeParams = {{$routeParams}}</pre>
  438. * </div>
  439. * </file>
  440. *
  441. * <file name="book.html">
  442. * controller: {{name}}<br />
  443. * Book Id: {{params.bookId}}<br />
  444. * </file>
  445. *
  446. * <file name="chapter.html">
  447. * controller: {{name}}<br />
  448. * Book Id: {{params.bookId}}<br />
  449. * Chapter Id: {{params.chapterId}}
  450. * </file>
  451. *
  452. * <file name="script.js">
  453. * angular.module('ngRouteExample', ['ngRoute'])
  454. *
  455. * .controller('MainController', function($scope, $route, $routeParams, $location) {
  456. * $scope.$route = $route;
  457. * $scope.$location = $location;
  458. * $scope.$routeParams = $routeParams;
  459. * })
  460. *
  461. * .controller('BookController', function($scope, $routeParams) {
  462. * $scope.name = 'BookController';
  463. * $scope.params = $routeParams;
  464. * })
  465. *
  466. * .controller('ChapterController', function($scope, $routeParams) {
  467. * $scope.name = 'ChapterController';
  468. * $scope.params = $routeParams;
  469. * })
  470. *
  471. * .config(function($routeProvider, $locationProvider) {
  472. * $routeProvider
  473. * .when('/Book/:bookId', {
  474. * templateUrl: 'book.html',
  475. * controller: 'BookController',
  476. * resolve: {
  477. * // I will cause a 1 second delay
  478. * delay: function($q, $timeout) {
  479. * var delay = $q.defer();
  480. * $timeout(delay.resolve, 1000);
  481. * return delay.promise;
  482. * }
  483. * }
  484. * })
  485. * .when('/Book/:bookId/ch/:chapterId', {
  486. * templateUrl: 'chapter.html',
  487. * controller: 'ChapterController'
  488. * });
  489. *
  490. * // configure html5 to get links working on jsfiddle
  491. * $locationProvider.html5Mode(true);
  492. * });
  493. *
  494. * </file>
  495. *
  496. * <file name="protractor.js" type="protractor">
  497. * it('should load and compile correct template', function() {
  498. * element(by.linkText('Moby: Ch1')).click();
  499. * var content = element(by.css('[ng-view]')).getText();
  500. * expect(content).toMatch(/controller: ChapterController/);
  501. * expect(content).toMatch(/Book Id: Moby/);
  502. * expect(content).toMatch(/Chapter Id: 1/);
  503. *
  504. * element(by.partialLinkText('Scarlet')).click();
  505. *
  506. * content = element(by.css('[ng-view]')).getText();
  507. * expect(content).toMatch(/controller: BookController/);
  508. * expect(content).toMatch(/Book Id: Scarlet/);
  509. * });
  510. * </file>
  511. * </example>
  512. */
  513. /**
  514. * @ngdoc event
  515. * @name $route#$routeChangeStart
  516. * @eventType broadcast on root scope
  517. * @description
  518. * Broadcasted before a route change. At this point the route services starts
  519. * resolving all of the dependencies needed for the route change to occur.
  520. * Typically this involves fetching the view template as well as any dependencies
  521. * defined in `resolve` route property. Once all of the dependencies are resolved
  522. * `$routeChangeSuccess` is fired.
  523. *
  524. * The route change (and the `$location` change that triggered it) can be prevented
  525. * by calling `preventDefault` method of the event. See {@link ng.$rootScope.Scope#$on}
  526. * for more details about event object.
  527. *
  528. * @param {Object} angularEvent Synthetic event object.
  529. * @param {Route} next Future route information.
  530. * @param {Route} current Current route information.
  531. */
  532. /**
  533. * @ngdoc event
  534. * @name $route#$routeChangeSuccess
  535. * @eventType broadcast on root scope
  536. * @description
  537. * Broadcasted after a route change has happened successfully.
  538. * The `resolve` dependencies are now available in the `current.locals` property.
  539. *
  540. * {@link ngRoute.directive:ngView ngView} listens for the directive
  541. * to instantiate the controller and render the view.
  542. *
  543. * @param {Object} angularEvent Synthetic event object.
  544. * @param {Route} current Current route information.
  545. * @param {Route|Undefined} previous Previous route information, or undefined if current is
  546. * first route entered.
  547. */
  548. /**
  549. * @ngdoc event
  550. * @name $route#$routeChangeError
  551. * @eventType broadcast on root scope
  552. * @description
  553. * Broadcasted if a redirection function fails or any redirection or resolve promises are
  554. * rejected.
  555. *
  556. * @param {Object} angularEvent Synthetic event object
  557. * @param {Route} current Current route information.
  558. * @param {Route} previous Previous route information.
  559. * @param {Route} rejection The thrown error or the rejection reason of the promise. Usually
  560. * the rejection reason is the error that caused the promise to get rejected.
  561. */
  562. /**
  563. * @ngdoc event
  564. * @name $route#$routeUpdate
  565. * @eventType broadcast on root scope
  566. * @description
  567. * Broadcasted if the same instance of a route (including template, controller instance,
  568. * resolved dependencies, etc.) is being reused. This can happen if either `reloadOnSearch` or
  569. * `reloadOnUrl` has been set to `false`.
  570. *
  571. * @param {Object} angularEvent Synthetic event object
  572. * @param {Route} current Current/previous route information.
  573. */
  574. var forceReload = false,
  575. preparedRoute,
  576. preparedRouteIsUpdateOnly,
  577. $route = {
  578. routes: routes,
  579. /**
  580. * @ngdoc method
  581. * @name $route#reload
  582. *
  583. * @description
  584. * Causes `$route` service to reload the current route even if
  585. * {@link ng.$location $location} hasn't changed.
  586. *
  587. * As a result of that, {@link ngRoute.directive:ngView ngView}
  588. * creates new scope and reinstantiates the controller.
  589. */
  590. reload: function() {
  591. forceReload = true;
  592. var fakeLocationEvent = {
  593. defaultPrevented: false,
  594. preventDefault: function fakePreventDefault() {
  595. this.defaultPrevented = true;
  596. forceReload = false;
  597. }
  598. };
  599. $rootScope.$evalAsync(function() {
  600. prepareRoute(fakeLocationEvent);
  601. if (!fakeLocationEvent.defaultPrevented) commitRoute();
  602. });
  603. },
  604. /**
  605. * @ngdoc method
  606. * @name $route#updateParams
  607. *
  608. * @description
  609. * Causes `$route` service to update the current URL, replacing
  610. * current route parameters with those specified in `newParams`.
  611. * Provided property names that match the route's path segment
  612. * definitions will be interpolated into the location's path, while
  613. * remaining properties will be treated as query params.
  614. *
  615. * @param {!Object<string, string>} newParams mapping of URL parameter names to values
  616. */
  617. updateParams: function(newParams) {
  618. if (this.current && this.current.$$route) {
  619. newParams = angular.extend({}, this.current.params, newParams);
  620. $location.path(interpolate(this.current.$$route.originalPath, newParams));
  621. // interpolate modifies newParams, only query params are left
  622. $location.search(newParams);
  623. } else {
  624. throw $routeMinErr('norout', 'Tried updating route with no current route');
  625. }
  626. }
  627. };
  628. $rootScope.$on('$locationChangeStart', prepareRoute);
  629. $rootScope.$on('$locationChangeSuccess', commitRoute);
  630. return $route;
  631. /////////////////////////////////////////////////////
  632. /**
  633. * @param on {string} current url
  634. * @param route {Object} route regexp to match the url against
  635. * @return {?Object}
  636. *
  637. * @description
  638. * Check if the route matches the current url.
  639. *
  640. * Inspired by match in
  641. * visionmedia/express/lib/router/router.js.
  642. */
  643. function switchRouteMatcher(on, route) {
  644. var keys = route.keys,
  645. params = {};
  646. if (!route.regexp) return null;
  647. var m = route.regexp.exec(on);
  648. if (!m) return null;
  649. for (var i = 1, len = m.length; i < len; ++i) {
  650. var key = keys[i - 1];
  651. var val = m[i];
  652. if (key && val) {
  653. params[key.name] = val;
  654. }
  655. }
  656. return params;
  657. }
  658. function prepareRoute($locationEvent) {
  659. var lastRoute = $route.current;
  660. preparedRoute = parseRoute();
  661. preparedRouteIsUpdateOnly = isNavigationUpdateOnly(preparedRoute, lastRoute);
  662. if (!preparedRouteIsUpdateOnly && (lastRoute || preparedRoute)) {
  663. if ($rootScope.$broadcast('$routeChangeStart', preparedRoute, lastRoute).defaultPrevented) {
  664. if ($locationEvent) {
  665. $locationEvent.preventDefault();
  666. }
  667. }
  668. }
  669. }
  670. function commitRoute() {
  671. var lastRoute = $route.current;
  672. var nextRoute = preparedRoute;
  673. if (preparedRouteIsUpdateOnly) {
  674. lastRoute.params = nextRoute.params;
  675. angular.copy(lastRoute.params, $routeParams);
  676. $rootScope.$broadcast('$routeUpdate', lastRoute);
  677. } else if (nextRoute || lastRoute) {
  678. forceReload = false;
  679. $route.current = nextRoute;
  680. var nextRoutePromise = $q.resolve(nextRoute);
  681. $browser.$$incOutstandingRequestCount('$route');
  682. nextRoutePromise.
  683. then(getRedirectionData).
  684. then(handlePossibleRedirection).
  685. then(function(keepProcessingRoute) {
  686. return keepProcessingRoute && nextRoutePromise.
  687. then(resolveLocals).
  688. then(function(locals) {
  689. // after route change
  690. if (nextRoute === $route.current) {
  691. if (nextRoute) {
  692. nextRoute.locals = locals;
  693. angular.copy(nextRoute.params, $routeParams);
  694. }
  695. $rootScope.$broadcast('$routeChangeSuccess', nextRoute, lastRoute);
  696. }
  697. });
  698. }).catch(function(error) {
  699. if (nextRoute === $route.current) {
  700. $rootScope.$broadcast('$routeChangeError', nextRoute, lastRoute, error);
  701. }
  702. }).finally(function() {
  703. // Because `commitRoute()` is called from a `$rootScope.$evalAsync` block (see
  704. // `$locationWatch`), this `$$completeOutstandingRequest()` call will not cause
  705. // `outstandingRequestCount` to hit zero. This is important in case we are redirecting
  706. // to a new route which also requires some asynchronous work.
  707. $browser.$$completeOutstandingRequest(noop, '$route');
  708. });
  709. }
  710. }
  711. function getRedirectionData(route) {
  712. var data = {
  713. route: route,
  714. hasRedirection: false
  715. };
  716. if (route) {
  717. if (route.redirectTo) {
  718. if (angular.isString(route.redirectTo)) {
  719. data.path = interpolate(route.redirectTo, route.params);
  720. data.search = route.params;
  721. data.hasRedirection = true;
  722. } else {
  723. var oldPath = $location.path();
  724. var oldSearch = $location.search();
  725. var newUrl = route.redirectTo(route.pathParams, oldPath, oldSearch);
  726. if (angular.isDefined(newUrl)) {
  727. data.url = newUrl;
  728. data.hasRedirection = true;
  729. }
  730. }
  731. } else if (route.resolveRedirectTo) {
  732. return $q.
  733. resolve($injector.invoke(route.resolveRedirectTo)).
  734. then(function(newUrl) {
  735. if (angular.isDefined(newUrl)) {
  736. data.url = newUrl;
  737. data.hasRedirection = true;
  738. }
  739. return data;
  740. });
  741. }
  742. }
  743. return data;
  744. }
  745. function handlePossibleRedirection(data) {
  746. var keepProcessingRoute = true;
  747. if (data.route !== $route.current) {
  748. keepProcessingRoute = false;
  749. } else if (data.hasRedirection) {
  750. var oldUrl = $location.url();
  751. var newUrl = data.url;
  752. if (newUrl) {
  753. $location.
  754. url(newUrl).
  755. replace();
  756. } else {
  757. newUrl = $location.
  758. path(data.path).
  759. search(data.search).
  760. replace().
  761. url();
  762. }
  763. if (newUrl !== oldUrl) {
  764. // Exit out and don't process current next value,
  765. // wait for next location change from redirect
  766. keepProcessingRoute = false;
  767. }
  768. }
  769. return keepProcessingRoute;
  770. }
  771. function resolveLocals(route) {
  772. if (route) {
  773. var locals = angular.extend({}, route.resolve);
  774. angular.forEach(locals, function(value, key) {
  775. locals[key] = angular.isString(value) ?
  776. $injector.get(value) :
  777. $injector.invoke(value, null, null, key);
  778. });
  779. var template = getTemplateFor(route);
  780. if (angular.isDefined(template)) {
  781. locals['$template'] = template;
  782. }
  783. return $q.all(locals);
  784. }
  785. }
  786. function getTemplateFor(route) {
  787. var template, templateUrl;
  788. if (angular.isDefined(template = route.template)) {
  789. if (angular.isFunction(template)) {
  790. template = template(route.params);
  791. }
  792. } else if (angular.isDefined(templateUrl = route.templateUrl)) {
  793. if (angular.isFunction(templateUrl)) {
  794. templateUrl = templateUrl(route.params);
  795. }
  796. if (angular.isDefined(templateUrl)) {
  797. route.loadedTemplateUrl = $sce.valueOf(templateUrl);
  798. template = $templateRequest(templateUrl);
  799. }
  800. }
  801. return template;
  802. }
  803. /**
  804. * @returns {Object} the current active route, by matching it against the URL
  805. */
  806. function parseRoute() {
  807. // Match a route
  808. var params, match;
  809. angular.forEach(routes, function(route, path) {
  810. if (!match && (params = switchRouteMatcher($location.path(), route))) {
  811. match = inherit(route, {
  812. params: angular.extend({}, $location.search(), params),
  813. pathParams: params});
  814. match.$$route = route;
  815. }
  816. });
  817. // No route matched; fallback to "otherwise" route
  818. return match || routes[null] && inherit(routes[null], {params: {}, pathParams:{}});
  819. }
  820. /**
  821. * @param {Object} newRoute - The new route configuration (as returned by `parseRoute()`).
  822. * @param {Object} oldRoute - The previous route configuration (as returned by `parseRoute()`).
  823. * @returns {boolean} Whether this is an "update-only" navigation, i.e. the URL maps to the same
  824. * route and it can be reused (based on the config and the type of change).
  825. */
  826. function isNavigationUpdateOnly(newRoute, oldRoute) {
  827. // IF this is not a forced reload
  828. return !forceReload
  829. // AND both `newRoute`/`oldRoute` are defined
  830. && newRoute && oldRoute
  831. // AND they map to the same Route Definition Object
  832. && (newRoute.$$route === oldRoute.$$route)
  833. // AND `reloadOnUrl` is disabled
  834. && (!newRoute.reloadOnUrl
  835. // OR `reloadOnSearch` is disabled
  836. || (!newRoute.reloadOnSearch
  837. // AND both routes have the same path params
  838. && angular.equals(newRoute.pathParams, oldRoute.pathParams)
  839. )
  840. );
  841. }
  842. /**
  843. * @returns {string} interpolation of the redirect path with the parameters
  844. */
  845. function interpolate(string, params) {
  846. var result = [];
  847. angular.forEach((string || '').split(':'), function(segment, i) {
  848. if (i === 0) {
  849. result.push(segment);
  850. } else {
  851. var segmentMatch = segment.match(/(\w+)(?:[?*])?(.*)/);
  852. var key = segmentMatch[1];
  853. result.push(params[key]);
  854. result.push(segmentMatch[2] || '');
  855. delete params[key];
  856. }
  857. });
  858. return result.join('');
  859. }
  860. }];
  861. }
  862. instantiateRoute.$inject = ['$injector'];
  863. function instantiateRoute($injector) {
  864. if (isEagerInstantiationEnabled) {
  865. // Instantiate `$route`
  866. $injector.get('$route');
  867. }
  868. }
  869. ngRouteModule.provider('$routeParams', $RouteParamsProvider);
  870. /**
  871. * @ngdoc service
  872. * @name $routeParams
  873. * @requires $route
  874. * @this
  875. *
  876. * @description
  877. * The `$routeParams` service allows you to retrieve the current set of route parameters.
  878. *
  879. * Requires the {@link ngRoute `ngRoute`} module to be installed.
  880. *
  881. * The route parameters are a combination of {@link ng.$location `$location`}'s
  882. * {@link ng.$location#search `search()`} and {@link ng.$location#path `path()`}.
  883. * The `path` parameters are extracted when the {@link ngRoute.$route `$route`} path is matched.
  884. *
  885. * In case of parameter name collision, `path` params take precedence over `search` params.
  886. *
  887. * The service guarantees that the identity of the `$routeParams` object will remain unchanged
  888. * (but its properties will likely change) even when a route change occurs.
  889. *
  890. * Note that the `$routeParams` are only updated *after* a route change completes successfully.
  891. * This means that you cannot rely on `$routeParams` being correct in route resolve functions.
  892. * Instead you can use `$route.current.params` to access the new route's parameters.
  893. *
  894. * @example
  895. * ```js
  896. * // Given:
  897. * // URL: http://server.com/index.html#/Chapter/1/Section/2?search=moby
  898. * // Route: /Chapter/:chapterId/Section/:sectionId
  899. * //
  900. * // Then
  901. * $routeParams ==> {chapterId:'1', sectionId:'2', search:'moby'}
  902. * ```
  903. */
  904. function $RouteParamsProvider() {
  905. this.$get = function() { return {}; };
  906. }
  907. ngRouteModule.directive('ngView', ngViewFactory);
  908. ngRouteModule.directive('ngView', ngViewFillContentFactory);
  909. /**
  910. * @ngdoc directive
  911. * @name ngView
  912. * @restrict ECA
  913. *
  914. * @description
  915. * `ngView` is a directive that complements the {@link ngRoute.$route $route} service by
  916. * including the rendered template of the current route into the main layout (`index.html`) file.
  917. * Every time the current route changes, the included view changes with it according to the
  918. * configuration of the `$route` service.
  919. *
  920. * Requires the {@link ngRoute `ngRoute`} module to be installed.
  921. *
  922. * @animations
  923. * | Animation | Occurs |
  924. * |----------------------------------|-------------------------------------|
  925. * | {@link ng.$animate#enter enter} | when the new element is inserted to the DOM |
  926. * | {@link ng.$animate#leave leave} | when the old element is removed from to the DOM |
  927. *
  928. * The enter and leave animation occur concurrently.
  929. *
  930. * @scope
  931. * @priority 400
  932. * @param {string=} onload Expression to evaluate whenever the view updates.
  933. *
  934. * @param {string=} autoscroll Whether `ngView` should call {@link ng.$anchorScroll
  935. * $anchorScroll} to scroll the viewport after the view is updated.
  936. *
  937. * - If the attribute is not set, disable scrolling.
  938. * - If the attribute is set without value, enable scrolling.
  939. * - Otherwise enable scrolling only if the `autoscroll` attribute value evaluated
  940. * as an expression yields a truthy value.
  941. * @example
  942. <example name="ngView-directive" module="ngViewExample"
  943. deps="angular-route.js;angular-animate.js"
  944. animations="true" fixBase="true">
  945. <file name="index.html">
  946. <div ng-controller="MainCtrl as main">
  947. Choose:
  948. <a href="Book/Moby">Moby</a> |
  949. <a href="Book/Moby/ch/1">Moby: Ch1</a> |
  950. <a href="Book/Gatsby">Gatsby</a> |
  951. <a href="Book/Gatsby/ch/4?key=value">Gatsby: Ch4</a> |
  952. <a href="Book/Scarlet">Scarlet Letter</a><br/>
  953. <div class="view-animate-container">
  954. <div ng-view class="view-animate"></div>
  955. </div>
  956. <hr />
  957. <pre>$location.path() = {{main.$location.path()}}</pre>
  958. <pre>$route.current.templateUrl = {{main.$route.current.templateUrl}}</pre>
  959. <pre>$route.current.params = {{main.$route.current.params}}</pre>
  960. <pre>$routeParams = {{main.$routeParams}}</pre>
  961. </div>
  962. </file>
  963. <file name="book.html">
  964. <div>
  965. controller: {{book.name}}<br />
  966. Book Id: {{book.params.bookId}}<br />
  967. </div>
  968. </file>
  969. <file name="chapter.html">
  970. <div>
  971. controller: {{chapter.name}}<br />
  972. Book Id: {{chapter.params.bookId}}<br />
  973. Chapter Id: {{chapter.params.chapterId}}
  974. </div>
  975. </file>
  976. <file name="animations.css">
  977. .view-animate-container {
  978. position:relative;
  979. height:100px!important;
  980. background:white;
  981. border:1px solid black;
  982. height:40px;
  983. overflow:hidden;
  984. }
  985. .view-animate {
  986. padding:10px;
  987. }
  988. .view-animate.ng-enter, .view-animate.ng-leave {
  989. transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 1.5s;
  990. display:block;
  991. width:100%;
  992. border-left:1px solid black;
  993. position:absolute;
  994. top:0;
  995. left:0;
  996. right:0;
  997. bottom:0;
  998. padding:10px;
  999. }
  1000. .view-animate.ng-enter {
  1001. left:100%;
  1002. }
  1003. .view-animate.ng-enter.ng-enter-active {
  1004. left:0;
  1005. }
  1006. .view-animate.ng-leave.ng-leave-active {
  1007. left:-100%;
  1008. }
  1009. </file>
  1010. <file name="script.js">
  1011. angular.module('ngViewExample', ['ngRoute', 'ngAnimate'])
  1012. .config(['$routeProvider', '$locationProvider',
  1013. function($routeProvider, $locationProvider) {
  1014. $routeProvider
  1015. .when('/Book/:bookId', {
  1016. templateUrl: 'book.html',
  1017. controller: 'BookCtrl',
  1018. controllerAs: 'book'
  1019. })
  1020. .when('/Book/:bookId/ch/:chapterId', {
  1021. templateUrl: 'chapter.html',
  1022. controller: 'ChapterCtrl',
  1023. controllerAs: 'chapter'
  1024. });
  1025. $locationProvider.html5Mode(true);
  1026. }])
  1027. .controller('MainCtrl', ['$route', '$routeParams', '$location',
  1028. function MainCtrl($route, $routeParams, $location) {
  1029. this.$route = $route;
  1030. this.$location = $location;
  1031. this.$routeParams = $routeParams;
  1032. }])
  1033. .controller('BookCtrl', ['$routeParams', function BookCtrl($routeParams) {
  1034. this.name = 'BookCtrl';
  1035. this.params = $routeParams;
  1036. }])
  1037. .controller('ChapterCtrl', ['$routeParams', function ChapterCtrl($routeParams) {
  1038. this.name = 'ChapterCtrl';
  1039. this.params = $routeParams;
  1040. }]);
  1041. </file>
  1042. <file name="protractor.js" type="protractor">
  1043. it('should load and compile correct template', function() {
  1044. element(by.linkText('Moby: Ch1')).click();
  1045. var content = element(by.css('[ng-view]')).getText();
  1046. expect(content).toMatch(/controller: ChapterCtrl/);
  1047. expect(content).toMatch(/Book Id: Moby/);
  1048. expect(content).toMatch(/Chapter Id: 1/);
  1049. element(by.partialLinkText('Scarlet')).click();
  1050. content = element(by.css('[ng-view]')).getText();
  1051. expect(content).toMatch(/controller: BookCtrl/);
  1052. expect(content).toMatch(/Book Id: Scarlet/);
  1053. });
  1054. </file>
  1055. </example>
  1056. */
  1057. /**
  1058. * @ngdoc event
  1059. * @name ngView#$viewContentLoaded
  1060. * @eventType emit on the current ngView scope
  1061. * @description
  1062. * Emitted every time the ngView content is reloaded.
  1063. */
  1064. ngViewFactory.$inject = ['$route', '$anchorScroll', '$animate'];
  1065. function ngViewFactory($route, $anchorScroll, $animate) {
  1066. return {
  1067. restrict: 'ECA',
  1068. terminal: true,
  1069. priority: 400,
  1070. transclude: 'element',
  1071. link: function(scope, $element, attr, ctrl, $transclude) {
  1072. var currentScope,
  1073. currentElement,
  1074. previousLeaveAnimation,
  1075. autoScrollExp = attr.autoscroll,
  1076. onloadExp = attr.onload || '';
  1077. scope.$on('$routeChangeSuccess', update);
  1078. update();
  1079. function cleanupLastView() {
  1080. if (previousLeaveAnimation) {
  1081. $animate.cancel(previousLeaveAnimation);
  1082. previousLeaveAnimation = null;
  1083. }
  1084. if (currentScope) {
  1085. currentScope.$destroy();
  1086. currentScope = null;
  1087. }
  1088. if (currentElement) {
  1089. previousLeaveAnimation = $animate.leave(currentElement);
  1090. previousLeaveAnimation.done(function(response) {
  1091. if (response !== false) previousLeaveAnimation = null;
  1092. });
  1093. currentElement = null;
  1094. }
  1095. }
  1096. function update() {
  1097. var locals = $route.current && $route.current.locals,
  1098. template = locals && locals.$template;
  1099. if (angular.isDefined(template)) {
  1100. var newScope = scope.$new();
  1101. var current = $route.current;
  1102. // Note: This will also link all children of ng-view that were contained in the original
  1103. // html. If that content contains controllers, ... they could pollute/change the scope.
  1104. // However, using ng-view on an element with additional content does not make sense...
  1105. // Note: We can't remove them in the cloneAttchFn of $transclude as that
  1106. // function is called before linking the content, which would apply child
  1107. // directives to non existing elements.
  1108. var clone = $transclude(newScope, function(clone) {
  1109. $animate.enter(clone, null, currentElement || $element).done(function onNgViewEnter(response) {
  1110. if (response !== false && angular.isDefined(autoScrollExp)
  1111. && (!autoScrollExp || scope.$eval(autoScrollExp))) {
  1112. $anchorScroll();
  1113. }
  1114. });
  1115. cleanupLastView();
  1116. });
  1117. currentElement = clone;
  1118. currentScope = current.scope = newScope;
  1119. currentScope.$emit('$viewContentLoaded');
  1120. currentScope.$eval(onloadExp);
  1121. } else {
  1122. cleanupLastView();
  1123. }
  1124. }
  1125. }
  1126. };
  1127. }
  1128. // This directive is called during the $transclude call of the first `ngView` directive.
  1129. // It will replace and compile the content of the element with the loaded template.
  1130. // We need this directive so that the element content is already filled when
  1131. // the link function of another directive on the same element as ngView
  1132. // is called.
  1133. ngViewFillContentFactory.$inject = ['$compile', '$controller', '$route'];
  1134. function ngViewFillContentFactory($compile, $controller, $route) {
  1135. return {
  1136. restrict: 'ECA',
  1137. priority: -400,
  1138. link: function(scope, $element) {
  1139. var current = $route.current,
  1140. locals = current.locals;
  1141. $element.html(locals.$template);
  1142. var link = $compile($element.contents());
  1143. if (current.controller) {
  1144. locals.$scope = scope;
  1145. var controller = $controller(current.controller, locals);
  1146. if (current.controllerAs) {
  1147. scope[current.controllerAs] = controller;
  1148. }
  1149. $element.data('$ngControllerController', controller);
  1150. $element.children().data('$ngControllerController', controller);
  1151. }
  1152. scope[current.resolveAs || '$resolve'] = locals;
  1153. link(scope);
  1154. }
  1155. };
  1156. }
  1157. })(window, window.angular);