相关疑难解决方法(0)

AngularJS:如何从ui-grid cell模板访问范围?

如何$scope从ui-grid单元模板访问?这是我的控制器代码:

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>'
    }]
  };
}]);
Run Code Online (Sandbox Code Playgroud)

请在此处查看:http: //plnkr.co/edit/WYXeQShHWKDYDs4MIZnP?p = preview

我希望细胞内容显示"你好世界",但他们只是显示"你好".

javascript angularjs angular-ui-grid

41
推荐指数
1
解决办法
4万
查看次数

标签 统计

angular-ui-grid ×1

angularjs ×1

javascript ×1