AngularJS: ¿Cómo acceder al alcance desde la plantilla de celda ui-grid?
¿Cómo se accede?$scope
de una plantilla de celda ui-grid? Aquí está mi código de controlador:
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>'
}]
};
}]);
Véalo en acción aquí:http://plnkr.co/edit/WYXeQShHWKDYDs4MIZnP?p=preview
Esperaría que el contenido de la celda muestre "hola mundo", pero solo muestran "hola".