-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Interpolation): Handle custom symbols
* Add a postProcessTemplate() function to the gridUtil service that swaps out interpolation symbols if they're different from the default ones. * Change getTemplate() to use this function when returning templates * Add tests to the gridUtil spec for getTemplate() with custom interpolation symbols Fixes #1576
- Loading branch information
Showing
3 changed files
with
179 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
@ngdoc overview | ||
@name Tutorial: 313 Custom Interpolation Symbols | ||
@description | ||
|
||
Combining AngularJS with other frameworks/tools sometimes requires changing the normal interpolation symbols (`{{` and `}}`) to something else, like `[[` or `%`. | ||
<br> | ||
<br> | ||
UI Grid will automatically detect the change and transform any default symbols in the templates it uses to the custom values. This means that in the unlikely event | ||
you're expecting to use `{{` or `}}` to signify something in your custom-interpolation-symbol application, then inside the grid your stuff will likely break. | ||
|
||
<example module="app"> | ||
<file name="app.js"> | ||
var app = angular.module('app', ['ngAnimate', 'ui.grid']); | ||
|
||
app.config(function($interpolateProvider) { | ||
$interpolateProvider.startSymbol('[['); | ||
$interpolateProvider.endSymbol(']]'); | ||
}); | ||
|
||
app.controller('MainCtrl', ['$scope', '$http', '$interpolate', function ($scope, $http, $interpolate) { | ||
$scope.foo = 'whoohoo!'; | ||
$scope.startSym = $interpolate.startSymbol(); | ||
$scope.endSym = $interpolate.endSymbol(); | ||
|
||
$scope.gridOptions = { | ||
enableSorting: true, | ||
columnDefs: [ | ||
{ field: 'name' }, | ||
{ field: 'gender' }, | ||
{ field: 'company', enableSorting: false } | ||
] | ||
}; | ||
|
||
$http.get('/data/100.json') | ||
.success(function(data) { | ||
$scope.gridOptions.data = data; | ||
}); | ||
}]); | ||
</file> | ||
<file name="index.html"> | ||
<div ng-controller="MainCtrl"> | ||
This app uses [[ startSym ]] and [[ endSym ]] for interpolation symbols: [[ foo ]] | ||
<br> | ||
<br> | ||
<div ui-grid="gridOptions" class="grid"></div> | ||
</div> | ||
</file> | ||
<file name="main.css"> | ||
.grid { | ||
width: 500px; | ||
height: 300px; | ||
} | ||
</file> | ||
</example> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters