谁能告诉我我的男女同志出了什么问题:
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();
}
html文件非常简单,我只想测试路由,因为我注意到这方面发生了许多变化:
家
新的条目
谢谢
最佳答案
感谢大家的帮助,现在我让他在以下代码下可以完美工作:
// 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';
}
和html文件是:
<!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>
关于dart - AngularDart路线,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25050122/