我从我的第一个AngularJS应用程序开始.我尝试使用angular-gulp-browserify-starter,并且工作正常.但现在我尝试添加ngTable,但gulp build说:
'NgTableParams' is not defined.
我正在尝试按照以下步骤操作:http://ng-table.com/.
1-添加带有凉亭的ng-table
bower install ng-table --save
2-将模块添加到app.js
var angular = require('angular'); angular.module('myApp', ['ngTable']); // this is the new line module.exports = angular.module('myApp', [ require('./common/common.js').name, require('./modules').name ]) .config(require('./appConfig')) .constant('version', require('../package.json').version) .run(require('./common/common-init.js'));
3-这是我的控制者
'use strict'; function TableCtrl($scope) { $scope.testVar = 'This my test for ngtable'; } TableCtrl.$inject = ['$scope']; module.exports = TableCtrl;
我把它放在哪里以及如何?
var self = this; var data = [{name: "Moroni", age: 50} /*,*/]; self.tableParams = new NgTableParams({}, { dataset: data});
我有像ng-table sitle说明那样的HTML.
谢谢!
var App = angular.module('AdminApp.Report.Controllers.Stores', ['ngMaterial','ngTable']); App.controller('SomeController', ['$scope', '$http','NgTableParams', function ($scope, $http, NgTableParams) { httpService.PostApiRequest(request,'/api/someUrl').then(function(data) { $scope.tableParams = new NgTableParams({}, { dataset: data}); }); } }]);
这是我选择中最简单的实现
我得到了同样的错误,文档缺少一点: - >你必须注入ngTableParams
控制器
我不是语法(我不使用这个)
function TableCtrl($scope) { $scope.testVar = 'This my test for ngtable'; // if this is your controller, every var you put in the $scope will be accessible in the view var data = [{name: "Moroni", age: 50} /*,*/]; $scope.tableParams = new NgTableParams({}, { dataset: data}); } TableCtrl.$inject = ["$scope","NgTableParams", "ngTableSimpleList"]; module.exports = TableCtrl;