package.json: as follows
{
"name": "tengai-medical",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack && webpack-dev-server --hot --inline"
},
"author": "Irene Tang",
"license": "ISC",
"devDependencies": {
"angular": "^1.2.27",
"angular-bootstrap": "0.12.2",
"css-loader": "^0.24.0",
"file-loader": "^0.9.0",
"html-webpack-plugin": "^2.22.0",
"node-sass": "^3.8.0",
"requirejs": "2.1.15",
"sass-loader": "^4.0.0",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^1.13.2",
"webpack-dev-server": "^1.15.1"
}
}
index.js
var angular = require('angular');
var bootstrap = require('angular-bootstrap');
angular.element(document).ready(function() {
var app = angular.module('multi-bootstrap', ['ui-bootstrap']);
app.controller('myController', ['$scope', '$modal', function($scope, $modal) {
}]);
angular.bootstrap(document, ['multi-bootstrap']);
})
现在我定义的myController需要用到$modal服务,这个服务在angular-bootstrap里,为什么require('angular')能拿到angular,require('angular-bootstrap')拿到的却是个空对象???新建模块的时候该怎么引入依赖模块???
angular-bootstrap is a folder under node_modules, which contains a js file of ui-bootstrap. Angular must be introduced first before require('angular-bootstrap/ui-bootstrap') is introduced, because it depends on angular. Finally When using it, it is ui.bootstrap instead of ui-bootstrap, because the module name defined in ui-bootstrap is ui.bootstrap
I think your package may be wrong, please change it to angular-ui-bootstrap.
You can look at the source code. There is the export keyword in angular, but there is no export in angular-bootstrap