【问题标题】:Where can i find the latest ionic-angular2 version in a plunker that uses @Ngmodule?我在哪里可以在使用 @Ngmodule 的 plunker 中找到最新的 ionic-angular2 版本?
【发布时间】:2023-03-22 15:38:01
【问题描述】:

我正在从这里学习ionic 2。 http://ionicframework.com/docs/v2/getting-started/tutorial/project-structure/ 我用简单的例子检查了 ionic 2 的在线编辑器。

https://plnkr.co/edit/SJ8GtqbRntby5yGzLEft?p=preview .但是没有使用Ngmodule的例子。我认为plunker是old。我们可以使用最新的ionic 2版本使用Ngmodule制作同样的例子。

@NgModule({
  declarations: [MyApp,HelloIonicPage, ItemDetailsPage, ListPage],
  imports: [IonicModule.forRoot(MyApp)],
  bootstrap: [IonicApp],
  entryComponents: [MyApp,HelloIonicPage,ItemDetailsPage,ListPage],
  providers: []
})
export class AppModule 
{} 

我们可以在 plunker 中使用最新的 ionic 版本制作 hello world 程序吗

【问题讨论】:

  • 我认为这更像是一个离子的东西,而不是一个框架?很难在浏览器中复制移动应用的完整路由。
  • 好的..我只需要hello world uisng ionic 2

标签: angular ionic2


【解决方案1】:

你可以看看我的Plunker Example ionic-angular@2.0.0-rc.1

Systemjs 配置看起来像:

(function(global) {
  var packages = {
    app: {
      main: './main.js',
      defaultExtension: 'js'
    },
    rxjs: {
      defaultExtension: 'js'
    },
    'ionic-angular': {
      main: 'index.js',
      defaultExtension: 'js'
    }
  };

  ['core',
    'common',
    'compiler',
    'forms',
    'http',
    'platform-browser',
    'platform-browser-dynamic',
    'router'
  ].forEach(function (name) {
    packages['@angular/' + name] = { main: 'index.js' };
  });

  var config = {
    transpiler: 'typescript',
    typescriptOptions: {
      emitDecoratorMetadata: true
    },
    paths: {
      'npm:': 'https://unpkg.com/'
    },
    map: {
      'app': 'src',
      '@angular': 'npm:@angular',
      'ionic-angular': 'npm:ionic-angular',
      'rxjs': 'npm:rxjs',
      'typescript': 'npm:typescript/lib/typescript.js'
    },
    //packages defines our app package
    packages: packages
  };

  System.config(config);
})(this);

希望这对您的编码有所帮助!

【讨论】:

    【解决方案2】:

    截至目前,this plunker seems to work, version: ionic-angular@2.0.0-rc.4

    这是 Systemjs 配置:

    /**
     * PLUNKER VERSION
     * (based on systemjs.config.js in angular.io)
     * System configuration for Angular samples
     * Adjust as necessary for your application needs.
     */
    (function (global) {
      System.config({
        // DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER
        transpiler: 'ts',
        typescriptOptions: {
          tsconfig: true
        },
        meta: {
          'typescript': {
            "exports": "ts"
          }
        },
        paths: {
          // paths serve as alias
          'npm:': 'https://unpkg.com/'
        },
        // map tells the System loader where to look for things
        map: {
          // our app is within the app folder
          app: 'app',
          pages: 'pages',
    
          // angular bundles
          '@angular/core': 'npm:@angular/core@2.2.1/bundles/core.umd.js',
          '@angular/common': 'npm:@angular/common@2.2.1/bundles/common.umd.js',
          '@angular/compiler': 'npm:@angular/compiler@2.2.1/bundles/compiler.umd.js',
          '@angular/platform-browser': 'npm:@angular/platform-browser@2.2.1/bundles/platform-browser.umd.js',
          '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic@2.2.1/bundles/platform-browser-dynamic.umd.js',
          '@angular/http': 'npm:@angular/http@2.2.1/bundles/http.umd.js',
          '@angular/forms': 'npm:@angular/forms@2.2.1/bundles/forms.umd.js',
    
          'ionic-angular': 'npm:ionic-angular@2.0.0-rc.4',
          'rxjs': 'npm:rxjs@5.0.0-beta.12',
          'ts': 'npm:plugin-typescript@5.3.1/lib/plugin.js',
          'typescript': 'npm:typescript@2.0.10/lib/typescript.js',
    
        },
        // packages tells the System loader how to load when no filename and/or no extension
        packages: {
          app: {
            main: './main.ts',
            defaultExtension: 'ts'
          },
          pages: {
            defaultExtension: 'ts'
          },
          rxjs: {
            defaultExtension: 'js'
          },
          'ionic-angular': {
            main: './umd/index.js',
            defaultExtension: 'js'
          }
        }
      });
    })(this);
    
    
    /*
    Copyright 2016 Google Inc. All Rights Reserved.
    Use of this source code is governed by an MIT-style license that
    can be found in the LICENSE file at http://angular.io/license
    */
    

    还有 tsconfig:

    {
      "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": true,
        "suppressImplicitAnyIndexErrors": true
      }
    }
    

    【讨论】:

      【解决方案3】:

      这是我创建的:http://plnkr.co/edit/y8R0MF?p=info

      已更新到 Ionic 3.2.1 和 angular 4.2.2 这很简单,但很有效

      // angular bundles
            '@angular/core': 'npm:@angular/core@4.1.2/bundles/core.umd.js',
            '@angular/common': 'npm:@angular/common@4.1.2/bundles/common.umd.js',
            '@angular/compiler': 'npm:@angular/compiler@4.1.2/bundles/compiler.umd.js',
            '@angular/platform-browser': 'npm:@angular/platform-browser@4.1.2/bundles/platform-browser.umd.js',
            '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic@4.1.2/bundles/platform-browser-dynamic.umd.js',
            '@angular/http': 'npm:@angular/http@4.1.2/bundles/http.umd.js',
            '@angular/forms': 'npm:@angular/forms@4.1.2/bundles/forms.umd.js',
      
            'ionic-angular': 'npm:ionic-angular@3.2.1',
            'rxjs': 'npm:rxjs@5.0.0-beta.12',
            'ts': 'npm:plugin-typescript@5.2.7/lib/plugin.js',
            'typescript': 'npm:typescript@2.0.7/lib/typescript.js',
      
          },
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-11-10
        • 2023-01-26
        • 2012-06-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多