1

To call ngBootstrap I used

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

Since polymer 0.10.0-pre.8 this seems not possible anymore:

Dartium currently only allows a single Dart script tag per application, and in the future it will run them in separtate isolates. To prepare for this all the following script tags need to be updated to use the mime-type "application/dart;component=1" instead of "application/dart":


     &smt;script type=​"application/​dart" src=​"main.dart"></script>


Only one Dart script tag allowed per document

But my main is not a component - it is a regular main!!!

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
Mike Mitterer
  • 6,810
  • 4
  • 41
  • 62

1 Answers1

1

Was easier than thought.

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();
}
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
Mike Mitterer
  • 6,810
  • 4
  • 41
  • 62
  • this was for some Polymer pre-releases and has changed back to the previous form see http://stackoverflow.com/questions/20932180 or http://stackoverflow.com/questions/20982489 – Günter Zöchbauer May 25 '14 at 13:21