From 10cc3f80b3e3fccf3de484807162bac8bb134005 Mon Sep 17 00:00:00 2001 From: Andy Perry Date: Thu, 3 Jul 2014 00:53:54 +0100 Subject: [PATCH 01/11] Make resolved injectables from ancestor states available in descendent state resolves. --- src/resolve.js | 9 +++++++++ test/resolveSpec.js | 22 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/resolve.js b/src/resolve.js index 6d8f381d2..ea30680cf 100644 --- a/src/resolve.js +++ b/src/resolve.js @@ -102,6 +102,7 @@ function $Resolve( $q, $injector) { if (!merged) merge(values, parent.$$values); result.$$values = values; result.$$promises = true; // keep for isResolve() + delete result.$$inheritedValues; resolution.resolve(values); } } @@ -117,12 +118,20 @@ function $Resolve( $q, $injector) { return result; } + if (parent.$$inheritedValues) { + merge(values, parent.$$inheritedValues); + } + // Merge parent values if the parent has already resolved, or merge // parent promises and wait if the parent resolve is still in progress. if (parent.$$values) { merged = merge(values, parent.$$values); + result.$$inheritedValues = parent.$$values; done(); } else { + if (parent.$$inheritedValues) { + result.$$inheritedValues = parent.$$inheritedValues; + } extend(promises, parent.$$promises); parent.then(done, fail); } diff --git a/test/resolveSpec.js b/test/resolveSpec.js index fda9e0ecc..67117b9ed 100644 --- a/test/resolveSpec.js +++ b/test/resolveSpec.js @@ -140,6 +140,28 @@ describe("resolve", function () { expect(b.mostRecentCall.args).toEqual([ 'aa' ]); }); + it("allow access to ancestor resolves in descendent resolve blocks", inject(function ($q) { + var gPromise = $q.defer(), + gInjectable = jasmine.createSpy('gInjectable').andReturn(gPromise.promise), + pPromise = $q.defer(), + pInjectable = jasmine.createSpy('pInjectable').andReturn(pPromise.promise); + + var g = $r.resolve({ gP: [ gInjectable ] }, g); + + gPromise.resolve('grandparent'); + tick(); + + var s = jasmine.createSpy('s'); + var p = $r.resolve({ p: [ pInjectable ] }, g); + var c = $r.resolve({ c: [ 'p', 'gP', s ] }, p); + + pPromise.resolve('parent'); + tick(); + + expect(s).toHaveBeenCalled(); + expect(s.mostRecentCall.args).toEqual([ 'parent', 'grandparent' ]); + })); + it("allows a function to override a parent value of the same name", function () { var r = $r.resolve({ b: function() { return 'B' } }); var s = $r.resolve({ From 831a92c048f8b36ed140bd3e135200af7d50931c Mon Sep 17 00:00:00 2001 From: Miguel SM Date: Sun, 22 Jun 2014 22:17:51 +0100 Subject: [PATCH 02/11] Change 'this' with $state in $state.go Allow partial application of $state.go as in _.partial($state.go, ...) --- src/state.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/state.js b/src/state.js index b0822b7ac..1986b1b22 100644 --- a/src/state.js +++ b/src/state.js @@ -716,7 +716,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) { * */ $state.go = function go(to, params, options) { - return this.transitionTo(to, params, extend({ inherit: true, relative: $state.$current }, options)); + return $state.transitionTo(to, params, extend({ inherit: true, relative: $state.$current }, options)); }; /** From e99b3b41ea831e8657bf98e865bb645e98970f20 Mon Sep 17 00:00:00 2001 From: Nick Heiner Date: Mon, 30 Jun 2014 20:04:00 -0400 Subject: [PATCH 03/11] Update README.md Add npm install instructions --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4b760cc78..a1a196c69 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ Check out the sample app: http://angular-ui.github.io/ui-router/sample/ - clone & [build](#developing) this repository - [download the release](http://angular-ui.github.io/ui-router/release/angular-ui-router.js) (or [minified](http://angular-ui.github.io/ui-router/release/angular-ui-router.min.js)) - via **[Bower](http://bower.io/)**: by running `$ bower install angular-ui-router` from your console + - or via **[npm](https://www.npmjs.org/)**: by running `$ npm install angular-ui-router` from your console - or via **[Component](https://github.com/component/component)**: by running `$ component install angular-ui/ui-router` from your console **(2)** Include `angular-ui-router.js` (or `angular-ui-router.min.js`) in your `index.html`, after including Angular itself (For Component users: ignore this step) From 45e88e2904d0784387d13b3ac6b3f499fc3f578e Mon Sep 17 00:00:00 2001 From: sroe Date: Wed, 2 Jul 2014 12:57:10 +0200 Subject: [PATCH 04/11] Restore comment in .run function call In a previous version there was a example of how to use the $state inside a ng-class. --- sample/app/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sample/app/app.js b/sample/app/app.js index eacc40127..10a82ecde 100644 --- a/sample/app/app.js +++ b/sample/app/app.js @@ -13,8 +13,8 @@ angular.module('uiRouterSample', [ // It's very handy to add references to $state and $stateParams to the $rootScope // so that you can access them from any scope within your applications.For example, - //
  • will set the
  • // to active whenever - // 'contacts.list' or one of its decendents is active. + //
  • will set the
  • + // to active whenever 'contacts.list' or one of its decendents is active. $rootScope.$state = $state; $rootScope.$stateParams = $stateParams; } From 8daa9448b0ceaabc7dfb1c5a6b92ac211bf57cd7 Mon Sep 17 00:00:00 2001 From: Tim Kindberg Date: Thu, 3 Jul 2014 22:10:49 -0400 Subject: [PATCH 05/11] chore(changelog): fix changelog is just plain wrong, was showing features that aren't even released yet. --- CHANGELOG.md | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51660184f..d9105632b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,31 +1,40 @@ - -### v0.2.10 (2014-04-08) +### 0.2.10 (2014-07-03) #### Bug Fixes -* **$state:** - * sanity-check state lookups ([456fd5ae](https://github.com/angular-ui/ui-router/commit/456fd5aec9ea507518927bfabd62b4afad4cf714), closes [#980](https://github.com/angular-ui/ui-router/issues/980)) - * didn't comply to inherit parameter ([09836781](https://github.com/angular-ui/ui-router/commit/09836781f126c1c485b06551eb9cfd4fa0f45c35)) -* **state:** allow view content loading broadcast ([7b78edee](https://github.com/angular-ui/ui-router/commit/7b78edeeb52a74abf4d3f00f79534033d5a08d1a)) -* **uiSref:** cancel transition if preventDefault() has been called ([2e6d9167](https://github.com/angular-ui/ui-router/commit/2e6d9167d3afbfbca6427e53e012f94fb5fb8022)) +* **$state:** use $browser.baseHref() when generating urls with .href() ([cbcc8488](https://github.com/angular-ui/ui-router/commit/cbcc84887d6b6d35258adabb97c714cd9c1e272d)) +* **bower.json:** JS files should not be ignored ([ccdab193](https://github.com/angular-ui/ui-router/commit/ccdab193315f304eb3be5f5b97c47a926c79263e)) +* **dev:** karma:background task is missing, can't run grunt:dev. ([d9f7b898](https://github.com/angular-ui/ui-router/commit/d9f7b898e8e3abb8c846b0faa16a382913d7b22b)) +* **sample:** Contacts menu button not staying active when navigating to detail states. Need t ([2fcb8443](https://github.com/angular-ui/ui-router/commit/2fcb84437cb43ade12682a92b764f13cac77dfe7)) +* **uiSref:** support mock-clicks/events with no data ([717d3ff7](https://github.com/angular-ui/ui-router/commit/717d3ff7d0ba72d239892dee562b401cdf90e418)) +* **uiView:** + * Do NOT autoscroll when autoscroll attr is missing ([affe5bd7](https://github.com/angular-ui/ui-router/commit/affe5bd785cdc3f02b7a9f64a52e3900386ec3a0), closes [#807](https://github.com/angular-ui/ui-router/issues/807)) + * Refactoring uiView directive to copy ngView logic ([548fab6a](https://github.com/angular-ui/ui-router/commit/548fab6ab9debc9904c5865c8bc68b4fc3271dd0), closes [#857](https://github.com/angular-ui/ui-router/issues/857), [#552](https://github.com/angular-ui/ui-router/issues/552)) #### Features -* **$state:** allow prevent syncUrl on failure ([753060b9](https://github.com/angular-ui/ui-router/commit/753060b910d5d2da600a6fa0757976e401c33172)) -* **$urlRouter:** abstract $location handling ([08b4636b](https://github.com/angular-ui/ui-router/commit/08b4636b294611f08db35f00641eb5211686fb50)) -* **uiSref:** extend syntax for ui-sref ([71cad3d6](https://github.com/angular-ui/ui-router/commit/71cad3d636508b5a9fe004775ad1f1adc0c80c3e)) -* **uiSrefActive:** Also activate for child states. ([bf163ad6](https://github.com/angular-ui/ui-router/commit/bf163ad6ce176ce28792696c8302d7cdf5c05a01), closes [#818](https://github.com/angular-ui/ui-router/issues/818)) +* **$state:** includes() allows glob patterns for state matching. ([2d5f6b37](https://github.com/angular-ui/ui-router/commit/2d5f6b37191a3135f4a6d9e8f344c54edcdc065b)) +* **UrlMatcher:** Add support for case insensitive url matching ([642d5247](https://github.com/angular-ui/ui-router/commit/642d524799f604811e680331002feec7199a1fb5)) +* **uiSref:** add support for transition options ([2ed7a728](https://github.com/angular-ui/ui-router/commit/2ed7a728cee6854b38501fbc1df6139d3de5b28a)) +* **uiView:** add controllerAs config with function ([1ee7334a](https://github.com/angular-ui/ui-router/commit/1ee7334a73efeccc9b95340e315cdfd59944762d)) + + +### 0.2.9 (2014-07-03) + - -### v0.2.8 (2014-01-16) +This release is identical to 0.2.8. 0.2.8 was re-tagged in git to fix a problem with bower. + + +### 0.2.8 (2014-07-03) #### Bug Fixes * **$state:** allow null to be passed as 'params' param ([094dc30e](https://github.com/angular-ui/ui-router/commit/094dc30e883e1bd14e50a475553bafeaade3b178)) * **$state.go:** param inheritance shouldn't inherit from siblings ([aea872e0](https://github.com/angular-ui/ui-router/commit/aea872e0b983cb433436ce5875df10c838fccedb)) +* **bower.json:** fixes bower.json ([eed3cc4d](https://github.com/angular-ui/ui-router/commit/eed3cc4d4dfef1d3ef84b9fd063127538ebf59d3)) * **uiSrefActive:** annotate controller injection ([85921422](https://github.com/angular-ui/ui-router/commit/85921422ff7fb0effed358136426d616cce3d583), closes [#671](https://github.com/angular-ui/ui-router/issues/671)) * **uiView:** * autoscroll tests pass on 1.2.4 & 1.1.5 ([86eacac0](https://github.com/angular-ui/ui-router/commit/86eacac09ca5e9000bd3b9c7ba6e2cc95d883a3a)) @@ -39,5 +48,4 @@ * **uiSref:** add target attribute behaviour ([c12bf9a5](https://github.com/angular-ui/ui-router/commit/c12bf9a520d30d70294e3d82de7661900f8e394e)) * **uiView:** * merge autoscroll expression test. ([b89e0f87](https://github.com/angular-ui/ui-router/commit/b89e0f871d5cc35c10925ede986c10684d5c9252)) - * cache and test autoscroll expression ([ee262282](https://github.com/angular-ui/ui-router/commit/ee2622828c2ce83807f006a459ac4e11406d9258)) - + * cache and test autoscroll expression ([ee262282](https://github.com/angular-ui/ui-router/commit/ee2622828c2ce83807f006a459ac4e11406d9258)) \ No newline at end of file From c6c11c2571043241950934364abd52b39855eaef Mon Sep 17 00:00:00 2001 From: Tim Kindberg Date: Thu, 3 Jul 2014 22:22:18 -0400 Subject: [PATCH 06/11] chore(changelog): fix changelog dates --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d9105632b..8312f0361 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 0.2.10 (2014-07-03) +### 0.2.10 (2014-03-12) #### Bug Fixes @@ -21,13 +21,13 @@ * **uiView:** add controllerAs config with function ([1ee7334a](https://github.com/angular-ui/ui-router/commit/1ee7334a73efeccc9b95340e315cdfd59944762d)) -### 0.2.9 (2014-07-03) +### 0.2.9 (2014-01-17) This release is identical to 0.2.8. 0.2.8 was re-tagged in git to fix a problem with bower. -### 0.2.8 (2014-07-03) +### 0.2.8 (2014-01-16) #### Bug Fixes From b171c33c3f9d3c00fea4a43386a77e6fc27f8698 Mon Sep 17 00:00:00 2001 From: Tim Kindberg Date: Fri, 4 Jul 2014 00:19:47 -0400 Subject: [PATCH 07/11] Added new resource links to videos and ui-router-extras --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a1a196c69..ddb9dd08a 100644 --- a/README.md +++ b/README.md @@ -227,11 +227,13 @@ myApp.config(function($stateProvider) { * [Sample App](http://angular-ui.github.com/ui-router/sample/) ([Source](https://github.com/angular-ui/ui-router/tree/gh-pages/sample)) * [FAQ](https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions) * [Slides comparing ngRoute to ui-router](http://slid.es/timkindberg/ui-router#/) +* [UI-Router Extras / Addons](http://christopherthielen.github.io/ui-router-extras/#/home) (@christopherthielen) ### Videos -* [Introduction Video](https://egghead.io/lessons/angularjs-introduction-ui-router)(egghead.io) +* [Introduction Video](https://egghead.io/lessons/angularjs-introduction-ui-router) (egghead.io) * [Tim Kindberg on Angular UI-Router](https://www.youtube.com/watch?v=lBqiZSemrqg) +* [Activating States](https://egghead.io/lessons/angularjs-ui-router-activating-states) (egghead.io) ## Report an Issue From 880ab3b9bfe19288cfd8b360bff4d719e6914265 Mon Sep 17 00:00:00 2001 From: Tim Kindberg Date: Tue, 15 Jul 2014 21:37:23 -0400 Subject: [PATCH 08/11] Linked example titles to plunkrs --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ddb9dd08a..c621f0100 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ When you're done, your setup should look similar to the following: ``` -### Nested States & Views +### [Nested States & Views](http://plnkr.co/edit/u18KQc?p=preview) The majority of UI-Router's power is in its ability to nest states & views. @@ -165,7 +165,7 @@ myApp.config(function($stateProvider, $urlRouterProvider) { >**[Dive Deeper!](https://github.com/angular-ui/ui-router/wiki)** -### Multiple & Named Views +### [Multiple & Named Views](http://plnkr.co/edit/SDOcGS?p=preview) Another great feature is the ability to have multiple `ui-view`s view per template. From 73cae2e64a667726bff733168ccea1ee03ffda81 Mon Sep 17 00:00:00 2001 From: Tim Kindberg Date: Tue, 15 Jul 2014 22:24:44 -0400 Subject: [PATCH 09/11] fix(docs): Explain return value of rule as function --- src/urlRouter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/urlRouter.js b/src/urlRouter.js index e4a76524f..eec2dfa22 100644 --- a/src/urlRouter.js +++ b/src/urlRouter.js @@ -88,14 +88,14 @@ function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) { * * // Example of using function rule as param * $urlRouterProvider.otherwise(function ($injector, $location) { - * ... + * return '/a/valid/url'; * }); * }); * * * @param {string|object} rule The url path you want to redirect to or a function * rule that returns the url path. The function version is passed two params: - * `$injector` and `$location` services. + * `$injector` and `$location` services, and must return a url string. * * @return {object} `$urlRouterProvider` - `$urlRouterProvider` instance */ From aa2a897697c97809ca624fb748a14a1de5973424 Mon Sep 17 00:00:00 2001 From: Andy Perry Date: Sat, 19 Jul 2014 14:23:00 +0100 Subject: [PATCH 10/11] Revert "Make resolved injectables from ancestor states available in descendent state resolves." This reverts commit 10cc3f80b3e3fccf3de484807162bac8bb134005. --- src/resolve.js | 9 --------- test/resolveSpec.js | 22 ---------------------- 2 files changed, 31 deletions(-) diff --git a/src/resolve.js b/src/resolve.js index ea30680cf..6d8f381d2 100644 --- a/src/resolve.js +++ b/src/resolve.js @@ -102,7 +102,6 @@ function $Resolve( $q, $injector) { if (!merged) merge(values, parent.$$values); result.$$values = values; result.$$promises = true; // keep for isResolve() - delete result.$$inheritedValues; resolution.resolve(values); } } @@ -118,20 +117,12 @@ function $Resolve( $q, $injector) { return result; } - if (parent.$$inheritedValues) { - merge(values, parent.$$inheritedValues); - } - // Merge parent values if the parent has already resolved, or merge // parent promises and wait if the parent resolve is still in progress. if (parent.$$values) { merged = merge(values, parent.$$values); - result.$$inheritedValues = parent.$$values; done(); } else { - if (parent.$$inheritedValues) { - result.$$inheritedValues = parent.$$inheritedValues; - } extend(promises, parent.$$promises); parent.then(done, fail); } diff --git a/test/resolveSpec.js b/test/resolveSpec.js index 67117b9ed..fda9e0ecc 100644 --- a/test/resolveSpec.js +++ b/test/resolveSpec.js @@ -140,28 +140,6 @@ describe("resolve", function () { expect(b.mostRecentCall.args).toEqual([ 'aa' ]); }); - it("allow access to ancestor resolves in descendent resolve blocks", inject(function ($q) { - var gPromise = $q.defer(), - gInjectable = jasmine.createSpy('gInjectable').andReturn(gPromise.promise), - pPromise = $q.defer(), - pInjectable = jasmine.createSpy('pInjectable').andReturn(pPromise.promise); - - var g = $r.resolve({ gP: [ gInjectable ] }, g); - - gPromise.resolve('grandparent'); - tick(); - - var s = jasmine.createSpy('s'); - var p = $r.resolve({ p: [ pInjectable ] }, g); - var c = $r.resolve({ c: [ 'p', 'gP', s ] }, p); - - pPromise.resolve('parent'); - tick(); - - expect(s).toHaveBeenCalled(); - expect(s.mostRecentCall.args).toEqual([ 'parent', 'grandparent' ]); - })); - it("allows a function to override a parent value of the same name", function () { var r = $r.resolve({ b: function() { return 'B' } }); var s = $r.resolve({ From 3faf69485d16a4807b82886853825cdb6cd0335a Mon Sep 17 00:00:00 2001 From: Andy Perry Date: Sat, 19 Jul 2014 14:27:49 +0100 Subject: [PATCH 11/11] fix($resolve): Resolves only inherit from immediate parent fixes #702 --- src/resolve.js | 9 +++++++++ test/resolveSpec.js | 22 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/resolve.js b/src/resolve.js index 6d8f381d2..ea30680cf 100644 --- a/src/resolve.js +++ b/src/resolve.js @@ -102,6 +102,7 @@ function $Resolve( $q, $injector) { if (!merged) merge(values, parent.$$values); result.$$values = values; result.$$promises = true; // keep for isResolve() + delete result.$$inheritedValues; resolution.resolve(values); } } @@ -117,12 +118,20 @@ function $Resolve( $q, $injector) { return result; } + if (parent.$$inheritedValues) { + merge(values, parent.$$inheritedValues); + } + // Merge parent values if the parent has already resolved, or merge // parent promises and wait if the parent resolve is still in progress. if (parent.$$values) { merged = merge(values, parent.$$values); + result.$$inheritedValues = parent.$$values; done(); } else { + if (parent.$$inheritedValues) { + result.$$inheritedValues = parent.$$inheritedValues; + } extend(promises, parent.$$promises); parent.then(done, fail); } diff --git a/test/resolveSpec.js b/test/resolveSpec.js index fda9e0ecc..67117b9ed 100644 --- a/test/resolveSpec.js +++ b/test/resolveSpec.js @@ -140,6 +140,28 @@ describe("resolve", function () { expect(b.mostRecentCall.args).toEqual([ 'aa' ]); }); + it("allow access to ancestor resolves in descendent resolve blocks", inject(function ($q) { + var gPromise = $q.defer(), + gInjectable = jasmine.createSpy('gInjectable').andReturn(gPromise.promise), + pPromise = $q.defer(), + pInjectable = jasmine.createSpy('pInjectable').andReturn(pPromise.promise); + + var g = $r.resolve({ gP: [ gInjectable ] }, g); + + gPromise.resolve('grandparent'); + tick(); + + var s = jasmine.createSpy('s'); + var p = $r.resolve({ p: [ pInjectable ] }, g); + var c = $r.resolve({ c: [ 'p', 'gP', s ] }, p); + + pPromise.resolve('parent'); + tick(); + + expect(s).toHaveBeenCalled(); + expect(s.mostRecentCall.args).toEqual([ 'parent', 'grandparent' ]); + })); + it("allows a function to override a parent value of the same name", function () { var r = $r.resolve({ b: function() { return 'B' } }); var s = $r.resolve({