2
votes

Can anyone tell me whats wrong in my coede:

import 'package:angular/angular.dart';
import 'package:angular/application_factory.dart';
import 'package:angular/routing/module.dart';

class myApp extends Module {
    myApp() {
        bind(RouteInitializerFn, toValue: initRoutes);
    }
}

void initRoutes(Router router, RouteViewFactory views) {
views.configure({
  'new': ngRoute(path: '/new', view: 'new.html'),
  'demohome': ngRoute(path: '/list', view: 'list.html')
 });
}

main() {

 var module = new Module()
  ..bind(myApp);

 applicationFactory().addModule(module).run();
}

the html file is very simple, I just want to test the route, as I noticed many changes happened in this regards: Home New Entry

thanks

1
Can you? Any error messages? Anything that doesn't work as expected? Maybe the links in the answer (and comments) to this question stackoverflow.com/questions/25009312 may give some guidance.Günter Zöchbauer

1 Answers

0
votes

Thanks to everyone tried to help, I got he below code work perfectly now:

  // the main.dart file;
      import 'package:angular/angular.dart';
      import 'package:angular/application_factory.dart';
      import 'package:angular/routing/module.dart';

      class myApp extends Module {
          myApp() {
            bind(RouteInitializerFn, toValue: initRoutes);
            bind(User);
          }
      }

      void initRoutes(Router router, RouteViewFactory views) {
      views.configure({
        'new': ngRoute(path: '/new', view: 'new.html'),
        'demohome': ngRoute(path: '/list', view: 'list.html')
       });
      }

      main() {         
        applicationFactory().addModule(new myApp()).run();
      }

      @Controller(
          selector: '[user-input]',
          publishAs: 'userCtrl') 

      class User {
        String userName = 'defaultName';
      }

and the html file is:

  <!doctype html>
  <html ng-app>

    <head>
      <meta charset="utf-8">
      <title>AngulrRoute Test</title>
      <link rel="stylesheet" href="todo.css">
    </head>

    <body>
        <h1>AngulrRoute Test</h1>

        <div user-input>Hello user {{userCtrl.userName}}!</div>

      <nav>
        <a href="/list">List</a>
        <a href="/new">New Entry</a>
      </nav>
      <ng-view></ng-view>


  <script type="application/dart" src="todo.dart"></script>
  <script type="text/javascript" src="packages/browser/dart.js"></script>


    </body>
  </html>