[英]AngularDart Route
誰能告訴我我的男女同志出了什么問題:
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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.