在定义应用程序时,我将 ng-grid 作为依赖项:
var app = angular.module('myApp', ['ngGrid']);
但并不是我所有的视图和控制器都需要 ngGrid,所以我在想是否可以在定义需要它的控制器时将 ngGrid 加载和注入应用程序?
我尝试了这样的事情,但没有奏效:
应用程序.js:
var app = angular.module('app',[]);
产品列表Ctrl.js:
define(['app', 'ng-grid'], function (app) {
'use strict';
app.register.controller('ProductListCtrl', ['$scope', 'ngGrid', function ($scope) {
name = $injector.get('ngGrid')
$scope.name = name
}]);
});
有什么建议么?