Skip to content

Commit 155142f

Browse files
document breaking change resolve inside a views block
Closes angular-ui/ui-router#3208
1 parent 8907fd8 commit 155142f

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

_guide/100. ng1-migration-to-1.0-from-legacy.md

+31-5
Original file line numberDiff line numberDiff line change
@@ -396,18 +396,44 @@ app.run(function($state) {
396396
})
397397
```
398398
399-
## Template Required
399+
## `resolve` inside `views`
400400
401-
Templates (or a component) are now required for all views.
401+
We no longer process `resolve` blocks that are declared inside a `views`.
402402
403-
If (for any reason) your state doesn't really need a template, use an empty one like so:
403+
404+
We used to allow resolves to be declared in a view:
404405
405406
```js
406-
$stateProvider.state('notemplate', {
407-
template: '<!-- -->'
407+
.state('foo', {
408+
views: {
409+
foo: {
410+
template: '<h1>foo</h1>',
411+
resolve: { fooData: () => 'fooData' },
412+
},
413+
bar: {
414+
template: '<h1>bar</h1>',
415+
resolve: { barData: () => 'barData' },
416+
}
417+
}
408418
})
409419
```
410420
421+
Now, move all resolves out to a `resolve` block on the state:
422+
423+
```js
424+
.state('foo', {
425+
views: {
426+
foo: { template: '<h1>foo</h1>' },
427+
bar: { template: '<h1>bar</h1>' },
428+
},
429+
resolve: {
430+
fooData: () => 'fooData',
431+
barData: () => 'barData',
432+
},
433+
})
434+
435+
```
436+
411437
## Prototypal inherited `.data`
412438
413439
This is technically a breaking change in 0.2.16, but is worth mentioning.

0 commit comments

Comments
 (0)