2017-08-05 73 views
0

我試圖找到一種方法來在我的angular2 +應用中包含第三方庫(urijs)。下面你會發現有關的文件。如何將URI.js庫包含在Angular2 +應用程序中?

// package.json 
{ 
    ... 
    "dependencies": { 
    ... 
    "urijs": "^1.18.10", 
    ... 
    } 
    ... 
} 

// .angular-cli.json 
{ 
    ... 
    "scripts": ["../node_modules/urijs/src/URI.js"], 
    ... 
} 

// file.service.js 
declare const URI: any; 
... 
... 
URI.expand(..); 

這樣做,我在運行我的應用程序時出錯。

ERROR TypeError: URI.expand is not a function 
at ProfileService.webpackJsonp.../../../../../src/app/shared/trakt/users/profile.service.ts.ProfileService.retrieveProfile (main.bundle.js:1071) 
at HeaderComponent.webpackJsonp.../../../../../src/app/home/header/header.component.ts.HeaderComponent.ngOnInit (main.bundle.js:239) 
at checkAndUpdateDirectiveInline (vendor.bundle.js:59912) 
at checkAndUpdateNodeInline (vendor.bundle.js:61408) 
at checkAndUpdateNode (vendor.bundle.js:61347) 
at debugCheckAndUpdateNode (vendor.bundle.js:62208) 
at debugCheckDirectivesFn (vendor.bundle.js:62149) 
at Object.eval [as updateDirectives] (ng:///HomeModule/HomeComponent.ngfactory.js:13) 
at Object.debugUpdateDirectives [as updateDirectives] (vendor.bundle.js:62134) 
at checkAndUpdateView (vendor.bundle.js:61314) 

任何想法,我怎麼能包括urijs庫?

感謝

回答

相關問題