gpt4 book ai didi

dart - 重装 Controller

转载 作者:行者123 更新时间:2023-12-03 04:07:05 26 4
gpt4 key购买 nike

我正在制作一个简单的测试网站,我想知道是否可以仅重新加载 Controller ,而无需重新加载整个页面。

<!DOCTYPE html>
<html ng-app>
<head lang="fr">
<meta charset="UTF-8">
<title>The Office</title>
<link rel="stylesheet" href="./css/style.css">
<script type="application/dart" src="main.dart"></script>
</head>
<body>
<div class="wrapper">

<nav nav-left ng-cloak>
<header>
<div ng-bind-html="user_infos"></div>
</header>
<ul>
<li ng-repeat="content in ctrl.menu_list"><a ng-class="ctrl.menu_class[content]" ng-click="ctrl.itemSelected(content)" href="{{ctrl.getLink(content)}}">{{content}}</a></li>
</ul>
</nav>

<main>
<h1>The Office</h1>
<ng-view></ng-view>
</main>

</div>
</body>
</html>

在这里,我正在寻找刷新nav-left。

这是我的组件:

import 'package:angular/angular.dart';

@Component(
selector: 'nav-left',
templateUrl: "/view/nav_left.html",
cssUrl: "/css/style.css",
publishAs: 'ctrl')
class NavLeft {
Scope scope;
...

NavLeft(this.scope);

void itemSelected(item) {
menu_class.forEach((k, v) {
menu_class[k] = (v == 'active') ? '' : v;
menu_class[k] = (k == item) ? 'active' : '';
});
}

String getLink(item) =>
menu_link[item];

而我正在尝试刷新它

library register;

import 'package:angular/angular.dart';
import 'package:Lawfice/service/ask_Server.dart';
import 'package:password_hasher/password_hasher.dart';
import 'dart:convert';
import 'dart:html';

@Controller(
selector: '[register-module]',
publishAs: 'ctrl')
class registerModule {
Router router;
Scope scope;
...

registerModule(this.router, this.scope);

...

void submit() {
if (checked_email == 'OK' && checked_pass == 'OK') {
Map<String, Map> data = {};
var hasher = new PasswordHasher();
var hash = hasher.hashPassword(pass1);

data['register'] = <String, String>{};
data['register']['email'] = email;
data['register']['password'] = hash;
_server.send(data).then((msg) {
if (msg == 'OK') {
router.go('news', {});
querySelector('nav-left').remove();
// What I'm suppose to do here ?
}

});
btn_class = 'btn btn-progress';
}
}
}

最佳答案

您可以删除然后重新插入标签。

您必须编译HTML以使Angular处理成为"new" HTML。
看看this questions的答案如何完成。

关于dart - 重装 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23224713/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com