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