使用最新的聚合物版本向ngBootstrap调用main显示错误

时间:2014-04-10 13:02:59

标签: dart dart-polymer angular-dart

要调用ngBootstrap我使用

void main() {
   initPolymer()
      .run(() {
        ngBootstrap(module: new AppModule());
      });
}

由于聚合物0.10.0-pre.8,这似乎不再可能:

Dartium目前只允许每个应用程序使用一个Dart脚本标记,并且将来它将在separtate隔离区中运行它们。为了做好准备,需要更新以下所有脚本标签以使用mime-type" application / dart; component = 1"而不是" application / dart":


     ⪪script type=​"application/​dart" src=​"main.dart"></script>


每个文档只允许一个Dart脚本标记

但我的主要不是一个组件 - 它是一个常规主力!!!

1 个答案:

答案 0 :(得分:1)

比思想容易。

的index.html:

<head>
    <script type='application/dart;component=1' src='main.dart'></script>
</head>

main.dart:

import 'package:polymer/polymer.dart';
import 'package:angular/angular.dart';
import 'package:angular/angular_dynamic.dart';

// HACK until we fix code gen size. This doesn't really fix it,
// just makes it better.
@MirrorsUsed(override: '*')
import 'dart:mirrors';

void myRouteInitializer(Router router, RouteViewFactory views) {
    views.configure({

        'hello': ngRoute(
            path: '/hello',
            enter: views('views/hello.html')),

        'goodbye': ngRoute(
            path: '/hellopolymer/:callerID',
            enter: views('views/hello-polymer.html'))

    });
}

@NgController( selector: '[webapp-sample]', publishAs: 'ctrl')
class MyControler {
    final Repository _repository;

    MyControler(final RouteProvider routeProvider,this._repository) {
        final int value = routeProvider.parameters["callerID"];
        if(value != null && value != null) {
            _repository.value = value;
        }

    }
    int get value =>  _repository.value;
}

class Repository {
    int value = 0;
}

class AppModule extends Module {
    AppModule() {

        value(RouteInitializerFn, myRouteInitializer);
        value(Repository,new Repository());

        type(MyControler);

        factory(NgRoutingUsePushState, (_) => new NgRoutingUsePushState.value(false));
    }
}

@initMethod
void init() {
    dynamicApplication().addModule(new AppModule()).run();
}