Skip to content

Commit

Permalink
docs(changelog, guide/migration): mention rare BC for ngInclude
Browse files Browse the repository at this point in the history
See angular#13555 (comment)
for detailed explanation.

Closes angular#13555
  • Loading branch information
Narretz committed Jun 7, 2016
1 parent 297a791 commit 2f61845
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 6 deletions.
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2043,6 +2043,44 @@ describe('$q.when', function() {
[#11580](https://github.com/angular/angular.js/issues/11580), [#12234](https://github.com/angular/angular.js/issues/12234))


## Breaking Changes

- **ngInclude:** due to [3c6e8ce044446735eb2e70d0061db8c6db050289](https://github.com/angular/angular.js/commit/3c6e8ce044446735eb2e70d0061db8c6db050289), the `src` attribute of ngInclude no longer accepts an
expression that returns the result of `$sce.trustAsResourceUrl`. This will now cause an infinite digest:

Before:
```html
<div ng-include="findTemplate('https://example.com/myTemplate.html')"></div>
```

```js
$scope.findTemplate = function(templateName) {
return $sce.trustAsResourceUrl(templateName);
};
```

To migrate, either cache the result of `trustAsResourceUrl()`, or put the template url in the resource
whitelist in the `config()` function:

After:

```js
var templateCache = {};
$scope.findTemplate = function(templateName) {
if (!templateCache[templateName]) {
templateCache[templateName] = $sce.trustAsResourceUrl(templateName);
}

return templateCache[templateName];
};

// Alternatively, use `$sceDelegateProvider.resourceUrlWhitelist()`:

angular.module('myApp', []).config(function($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhitelist(['self', 'https://example.com/**'])
});
```


<a name="1.3.17"></a>
# 1.3.17 tsktskskly-euouae (2015-07-06)
Expand Down
45 changes: 39 additions & 6 deletions docs/content/guide/migration.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ angular.module('myApp').directive('form', function() {
});
```

### Templating (`ngRepeat`, `$compile`)
### Templating (`ngRepeat`, `$compile`, `ngInclude`)

#### ngRepeat

Expand Down Expand Up @@ -545,6 +545,44 @@ Due to [62d514b](https://github.com/angular/angular.js/commit/62d514b06937cc7dd8
returning an object from a controller constructor function will now override the scope. Views that use the
controllerAs method will no longer get the this reference, but the returned object.

#### ngInclude
Due to [3c6e8ce044446735eb2e70d0061db8c6db050289](https://github.com/angular/angular.js/commit/3c6e8ce044446735eb2e70d0061db8c6db050289), the `src` attribute of ngInclude no longer accepts an
expression that returns the result of `$sce.trustAsResourceUrl`. This will now cause an infinite digest:

Before:
```html
<div ng-include="findTemplate('https://example.com/templates/myTemplate.html')"></div>
```

```js
$scope.findTemplate = function(templateName) {
return $sce.trustAsResourceUrl(templateName);
};
```

To migrate, either cache the result of `trustAsResourceUrl()`, or put the template url in the resource
whitelist in the `config()` function:

After:

```js
var templateCache = {};
$scope.findTemplate = function(templateName) {
if (!templateCache[templateName]) {
templateCache[templateName] = $sce.trustAsResourceUrl(templateName);
}

return templateCache[templateName];
};

// Alternatively, use `$sceDelegateProvider.resourceUrlWhitelist()`, which means you don't
// have to use `$sce.trustAsResourceUrl()` at all:

angular.module('myApp', []).config(function($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhitelist(['self', 'https://example.com/templates/**'])
});
```


### Cookies (`ngCookies`)

Expand Down Expand Up @@ -583,8 +621,6 @@ has been moved to `$cookies`, to which `$cookieStore` now simply
delegates calls.




### Server Requests (`$http`)

Due to [5da1256](https://github.com/angular/angular.js/commit/5da1256fc2812d5b28fb0af0de81256054856369),
Expand Down Expand Up @@ -616,8 +652,6 @@ $http.get(url, {
```




### Filters (`filter`, `limitTo`)

#### `filter` filter
Expand All @@ -636,7 +670,6 @@ Now, instead of returning empty object/array, it returns unchanged input.




## Migrating from 1.2 to 1.3

### Controllers
Expand Down

0 comments on commit 2f61845

Please sign in to comment.