0
NG2-dragula加载外部模块看起来很酷,但我有一些很难将其设置为我的角2项目。我用system.js
作为模块预加载和它的配置是:错误:要求是不是一个函数,而在角2
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
},
'ng2-bootstrap': {},
'ng2-dragula': { defaultExtension: 'js' }
},
map: {
'dragula': 'node_modules/dragula',
'ng2-bootstrap': 'node_modules/ng2-bootstrap',
'ng2-dragula': 'node_modules/ng2-dragula',
'moment': 'node_modules/moment/moment.js'
}
});
我tsconfig.json
:
{
"compilerOptions": {
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"watch": true
}
}
我如下加载它在我的组件:
import {DragulaService, Dragula} from 'ng2-dragula/ng2-dragula'
@Component({
selector: 'my-cmp',
viewProviders: [DragulaService],
})
@View({
template: '<div>Hey</div>',
directives: [Dragula]
})
我在做什么错误,导致我在浏览器中出现以下错误:
Error: require is not a function(…) angular2-polyfills.js:1243