Rumah > Soal Jawab > teks badan
package.json:如下
{
"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')拿到的却是个空对象???新建模块的时候该怎么引入依赖模块???
仅有的幸福2017-05-15 17:14:42
var angular = require('angular');
require('angular-bootstrap/ui-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']);
})
angular-bootstrap ialah folder di bawah node_modules, yang mengandungi fail js ui-bootstrap mesti diperkenalkan dahulu sebelum require('angular-bootstrap/ui-bootstrap') diperkenalkan, kerana ia bergantung pada sudut Akhirnya Apabila menggunakan ia adalah ui.bootstrap dan bukannya ui-bootstrap, kerana nama modul yang ditakrifkan dalam ui-bootstrap ialah ui.bootstrap
仅有的幸福2017-05-15 17:14:42
Saya rasa pakej anda mungkin salah, sila tukar kepada angular-ui-bootstrap.
Anda boleh melihat kod sumber Terdapat kata kunci eksport dalam sudut, tetapi tiada eksport dalam angular-bootstrap