标签: systemjs

Angular2:ng2-file-upload:无法使用SystemJS正确加载它

我正在使用systemJS来管理我的包,所以我已经将这些行添加到我的systemjs的配置文件中:

{
  map: { 'ng2-file-upload': 'node_modules/ng2-file-upload' },
  packages: {
    'ng2-file-upload': {
        main: './ng2-file-upload/ng2-file-upload.js', // also tried with './ng2-file-upload.js'
        defaultExtension: 'js'
    },
  }
}
Run Code Online (Sandbox Code Playgroud)

我导入NG2文件上传通过import { FileDrop, FileUploader } from 'ng2-file-upload';.

但导入导致我的应用程序"崩溃":我的typscript编译器似乎运行良好(我可以看到由于其他代码的日志),但修改不再被转换,所以我不能运行任何东西.我没有与ng2-file-upload相关的任何错误日志(除了很多Duplicate identifiers).

任何的想法 ?

编辑:我已经将这个包从node_modules我的应用程序(vendor)附近的文件夹中提取出来,并且我使用了相对路径导入FileDrop,FileUploader但是systemjs无法导入:

Error: SyntaxError: Unexpected token <(…)

编辑2:这是一些细节.我的应用程序在public其中包含2个子文件夹:srcbuild.我在里面写了ts代码src(很明显),我的tsc将转换后的文件保存到build.目前,我没有捆绑我的文件,因此里面的层次结构build与那个层次结构相同src.

但只有ng2-file-upload才会发生奇怪的事情:在转换过程中,tsc会在node_modules/ng2-file-upload里面添加一个文件夹build.这是树木: …

file-upload typescript systemjs angular

3
推荐指数
1
解决办法
1766
查看次数

模块'...'导入的意外值'undefined'

出现此错误:(SystemJS)模块'DossierModule'导入的意外值'undefined'

我有2个ngModules相互导入,这个错误可能来自那个吗?在那种情况下:DossierModule导入ContactModule,而ContactModule导入DossierModule.当我在ContactModule中删除导入时,它的工作原理与DossierModule相同.

那2个模块不能互相导入?

谢谢.

systemjs angular

3
推荐指数
1
解决办法
2393
查看次数

在 HTML 文件中使用 System.js 调用 typescript 类方法

我正在尝试 Typescript 和 System.js。Typescript 编译器使用 -w 标志运行。

我想在页面加载时调用一个方法,我可以导入播放,但不能使用“then”访问它:

HTML文件:

<!doctype html>
<head>
  <script src='//cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.41/system.js'> </script>
  <script>
    System.import('./play.js').then(function(play) { 
      play.start(); 
    });
  }
  </script>
</head>
<body>
</body>
Run Code Online (Sandbox Code Playgroud)

play.ts 文件:

export class Play {
  start() {
    alert('hello...');
  }
}
Run Code Online (Sandbox Code Playgroud)

我收到错误:Uncaught (in promise) TypeError: play.start is not a function。有任何想法吗?

typescript systemjs

3
推荐指数
1
解决办法
818
查看次数

angular-cli本地版本较低版本

我在全球范围内安装了最新版本的angular-cli.版本如下.

C:\Users\W055013\kumar\learn\rx>ng --version
As a forewarning, we are moving the CLI npm package to "@angular/cli" with the next release,
which will only support Node 6.9 and greater. This package will be officially deprecated
shortly after.

To disable this warning use "ng set --global warnings.packageDeprecation=false".


                             _                           _  _
  __ _  _ __    __ _  _   _ | |  __ _  _ __         ___ | |(_)
 / _` || '_ \  / _` || | | || | / _` || '__|_____ …
Run Code Online (Sandbox Code Playgroud)

systemjs webpack angular-cli angular

3
推荐指数
2
解决办法
8579
查看次数

业力测试中未定义 jQuery 错误

我在我的 angular 5 应用程序中使用 jQuery,它运行良好,但我在业力测试方面遇到了问题。

import { ElementRef } from '@angular/core';
declare var jQuery: any;

export class Item {

constructor(private element: ElementRef) {
    this.init();
}

private init() {
    this.$item = jQuery(this.element.nativeElement);
...
Run Code Online (Sandbox Code Playgroud)

错误

参考错误:未定义 jQuery。

包.json

"dependencies": {
  "jquery": "3.1.1"
}
Run Code Online (Sandbox Code Playgroud)

我已将 jquery 添加到我的 karma.conf 中,但这并没有帮助。

files: [
        'node_modules/core-js/client/shim.js',
        'node_modules/systemjs/dist/system.src.js',
        'node_modules/zone.js/dist/zone.js',
        'node_modules/zone.js/dist/proxy.js',
        'node_modules/zone.js/dist/sync-test.js',
        'node_modules/zone.js/dist/jasmine-patch.js',
        'node_modules/zone.js/dist/async-test.js',
        'node_modules/zone.js/dist/fake-async-test.js',
        'node_modules/tslib/tslib.js',
        'node_modules/jquery/dist/jquery.js',

        {pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
        {pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },
        {pattern: '../karma-test-shim.js', included: true, watched: true},
        {pattern: 'node_modules/@angular/**/*.js', …
Run Code Online (Sandbox Code Playgroud)

jquery systemjs angular5

3
推荐指数
1
解决办法
3220
查看次数

无法加载AngularJS 2路由器

我的Angular 2项目有问题.

结构:

- project
  - dev     
     - api
     - res
         - config
         - script
             - js
                 - components
                     - blog.components.js
                     - blog.components.js.map
                 - pipes
                 - services
                 - bootstrap.js
                 - bootstrap.js.map
             - ts
                 - components
                     - blog.components.ts
                 - pipes
                 - services
                 - bootstrap.ts
                 - tsconfig.json
         - style
             - css
             - sass
         - templates
             - components
                 - app.component.html
                 - blog.component.html
         - index.php
  - dist
     - api
     - res
         - config
         - script
             - js
                 - components
                    - blog.component.min.js
                 - pipes …
Run Code Online (Sandbox Code Playgroud)

javascript typescript gulp systemjs angular

2
推荐指数
1
解决办法
1646
查看次数

在跟踪Angular2 Quickstart for beta.0时无法加载boot.js.

我已升级到Angular2@2.0.0-beta.0.app.ts和boot.ts都在我的src目录中(与Quickstart中的app相比).src和index.html位于项目目录中 - angular2-oPost,与Quickstart示例类似.我已经尝试了很多东西但总是得到 - 找不到boot.js,错误加载boot.js我的index.html加载脚本全部加载并且是:

<base href="/src"/>
<!--1. Load library links for ES6-related imports, then load angular2 modules -->
<script src="./angular2-oPost/node_modules/systemjs/dist/system.src.js"></script>
<script src="./angular2-oPost/node_modules/angular2/bundles/angular2-polyfills.min.js"></script>
<script src="./angular2-oPost/node_modules/rxjs/bundles/Rx.js"></script> 
<script src="./angular2-oPost/node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="./angular2-oPost/node_modules/angular2/bundles/router.min.js"></script>
<!-- 2. Configure SystemJS -->
<script>System.config({
  packages: {
    src: {
      format: 'register',
      defaultExtension: 'js'
      }
    }
  });
  System.import('src/boot').then(null, console.error.bind(console));
</script>
Run Code Online (Sandbox Code Playgroud)

boot.ts来自Quickstart,简单地说:

"use strict";
import { bootstrap }    from 'angular2/platform/browser';
import { ResidenceApp } from './app';
bootstrap( ResidenceApp );
Run Code Online (Sandbox Code Playgroud)

app.ts有一些导入语句,@ Component,@ View,@ RouteConfig和一个bootstrap语句.没有加载.Console错误声明是:

GET http://localhost/src/boot.js [HTTP/1.1 404 Not Found 31ms]
15:53:05.058 Error: …
Run Code Online (Sandbox Code Playgroud)

javascript systemjs angular

2
推荐指数
1
解决办法
6462
查看次数

Angular2,按字符串/名称手动解析类型

是否可以通过仅知道它的名称来手动解析组件?

我有一个字符串变量,它将包含一个组件的名称,让我们说"UserService"

我需要能够解决这种类型,我看过Injctor,我可以从文档中看到有一个resolve()resolveAndCreate()(https://angular.io/docs/ts/latest/api/core/Injector-class.html)

但我没有Type.

谢谢

史蒂夫

编辑:尝试以下:

System.import("path/to/service").then(p=>{

     var injector = Injector.resolveAndCreate([p[this.serviceName]]);//works

     var serviceInstance = injector.get(p[this.serviceName]); //Fails with "No provider for Http! (UserService -> Http)".


});
Run Code Online (Sandbox Code Playgroud)

我有Http可用,它是在bootstrap期间提供的,这适用于应用程序的其他部分.

bootstrap(AppComponent, [
    ROUTER_PROVIDERS, Http, HTTP_PROVIDERS, UrlBuilderService,
    provide(LocationStrategy, { useClass: HashLocationStrategy }),
    provide('notification', { useClass: NotificationService })
]);
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

进一步编辑:

我现在称之为resolveAndCreate:

var injector = Injector.resolveAndCreate([p[this.serviceName], Http]);
Run Code Online (Sandbox Code Playgroud)

哪个失败了

没有ConnectionBackend的提供者!(UserService - > Http - > ConnectionBackend)

所以我称之为:

var injector = Injector.resolveAndCreate([p[this.serviceName], Http, …
Run Code Online (Sandbox Code Playgroud)

typescript systemjs angular

2
推荐指数
1
解决办法
2514
查看次数

在Angular2应用程序中使用GeoFire

我正在尝试在我的Angular2(RC5)应用程序中设置GeoFire.我已经用npm安装了geofire和firebase,并配置了systemjs来导入它.这是我的package.json:

{
  "name": "MyProject",
  "version": "0.1.0",
  "scripts": {
    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
    "lite": "lite-server",
    "postinstall": "typings install",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings"
  },
  "license": "ISC",
  "dependencies": {
    "@angular/common": "^2.0.0-rc.5",
    "@angular/compiler": "^2.0.0-rc.5",
    "@angular/core": "^2.0.0-rc.5",
    "@angular/forms": "0.3.0",
    "@angular/http": "2.0.0-rc.5",
    "@angular/platform-browser": "^2.0.0-rc.5",
    "@angular/platform-browser-dynamic": "^2.0.0-rc.5",
    "@angular/router": "3.0.0-rc.1",
    "@angular/router-deprecated": "2.0.0-rc.2",
    "@angular/upgrade": "2.0.0-rc.5",
    "angular2-in-memory-web-api": "0.0.15",
    "bootstrap": "^3.3.6",
    "core-js": "^2.4.0",
    "firebase": "^3.3.0",
    "geofire": "^4.1.1",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.6",
    "systemjs": "0.19.27",
    "zone.js": "^0.6.12"
  },
  "devDependencies": {
    "concurrently": "^2.0.0",
    "lite-server": …
Run Code Online (Sandbox Code Playgroud)

firebase systemjs geofire angular

2
推荐指数
1
解决办法
2881
查看次数

Angular 2:System.import():不使用完整路径

我使用下面两个不同的代码来导入文件运行时,其中一个工作正常,而另一个抛出错误.

工作:

 System.import('../../FileName.ts').then(classObj => {          
        console.log(classObj);            
 });
Run Code Online (Sandbox Code Playgroud)

不工作:

 System.import('App/Models/FileName.ts').then(classObj => {          
        console.log(classObj);            
 });
Run Code Online (Sandbox Code Playgroud)

它抛出以下错误:

找不到模块'App/Models/FileName.ts'

文件结构,其中编写代码,我也尝试从同一结构导入文件:

(1)代码:ActivityModel.ts(2)导入:ApplicationModel.ts

在此输入图像描述

任何人都可以帮我解决上述全路径考虑问题.

typescript systemjs angular

2
推荐指数
1
解决办法
1375
查看次数