哪里可以找到使用@Ngmodule的plunker中最新的ionic-angular2版本?

时间:2016-10-24 13:46:53

标签: angular ionic2

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

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

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

我们可以用plunker中的最新离子版本制作hello world程序

3 个答案:

答案 0 :(得分:2)

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

Systemjs config 如下所示:

import Foundation

typealias Currency = Double

extension Currency {
    var credit: Double { return self }
    var usd: Double { return self * 0.62 }

    func description() -> String {
        let price = self as NSNumber
        let formatter = NumberFormatter()
        formatter.numberStyle = .currency
        return formatter.string(from: price)!
    }

}

let price: Currency = 1000000000

print(price.description) 
/* It doesn't work, I want something like 1000,000,000.0 */

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

答案 1 :(得分:1)

截至此日期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
  }
}

答案 2 :(得分:0)

这是我创建的那个: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',

    },