AngularJS: Zugriff auf den Gültigkeitsbereich aus der UI-Grid-Zellenvorlage?
Wie greift man zu$scope
aus einer UI-Grid-Zellenvorlage? Hier ist mein Controller-Code:
app.controller('MainCtrl', ['$scope', function ($scope) {
// i want to reference this from a cell template.
$scope.world = function() { return 'world'; };
$scope.gridOptions = {
data: [
{ id: "item1" },
{ id: "item2" }
],
columnDefs: [
{
field: 'id',
// world() is never called and is not displayed.
cellTemplate: '<div>{{ "hello " + world() }}</div>'
}]
};
}]);
Siehe es hier in Aktion:http: //plnkr.co/edit/WYXeQShHWKDYDs4MIZnP? p = preview
Ich würde erwarten, dass der Inhalt der Zelle "Hallo Welt" anzeigt, aber sie zeigen nur "Hallo".