Dart的Web组件和Angular的指令看起来像是非常相似的目的.有什么重大差异吗?
在一个组件中包含许多不同组件的应用程序中,我有一个自定义自动建议框.如果用户点击自动建议框(或包含自动建议框的元素)的任何位置,则应关闭该框.
这就是我在jQuery中要做的事情:
$(document).on('click','body',function(e) {
if(e.target!='.suggestbox' && $(e.target).parent('.suggestbox').length <1 ) {
$('.suggestbox').remove();
}
});
Run Code Online (Sandbox Code Playgroud)
但是在我的Angular Dart模板中,我有:
index.html的:
<body>
<my-app>
// sub component
// sub sub component
</my-app>
</body>
Run Code Online (Sandbox Code Playgroud)
我可以想到在my-app组件中检测到最顶层包装器上的点击并将操作发送到子组件但是这仍然不是主体点击的可能性.
解决这个问题的最佳方法是什么?
我已经搜索了关于如何在Visual Studio Code上有效设置Angular Dart 5的文档,但到目前为止还没有找到任何结论.
我已经搜索过的地方:
用于dart的VS Code插件不提供创建新空项目的功能.所以我现在不知所措.
我如何在VS Code IDE上设置AngularDart 5项目?有人可以向我推荐相同的资源吗?
我有简单的Angular-Dart组件,尝试ngModel在单选输入中将connect属性设置为,应用正确编译,但是浏览器控制台给我错误:
No provider found for RadioControlRegistry: RadioControlValueAccessor -> RadioControlRegistry.
Run Code Online (Sandbox Code Playgroud)
代码:
import 'package:angular/angular.dart';
import 'package:angular_forms/angular_forms.dart';
@Component(
selector: 'order-question-test',
template: '''
<input type="radio" name="food" [(ngModel)]="foodChicken">
<input type="radio" name="food" [(ngModel)]="foodFish">
''',
directives: [
coreDirectives,
formDirectives,
]
)
class OrderQuestion {
RadioButtonState foodChicken = RadioButtonState(true, "chicken");
RadioButtonState foodFish = RadioButtonState(false, "fish");
OrderQuestion ();
}
Run Code Online (Sandbox Code Playgroud)
pubspec.yaml
environment:
sdk: '>=2.2.0 <3.0.0'
dependencies:
angular: ^5.2.0
angular_components: ^0.13.0
json_annotation: ^2.0.0
dev_dependencies:
angular_test: ^2.2.0
build_runner: ^1.5.0
build_test: ^0.10.3
build_web_compilers: ^1.0.0
json_serializable: ^2.0.0
pedantic: ^1.0.0
test: ^1.5.1
Run Code Online (Sandbox Code Playgroud)
怎么了?
有没有人知道像jsfiddle.net这样的在线服务,但是对于 Angular Dart Code?
我在看这个源代码:https://github.com/angular/angular.io/blob/master/public/docs/_examples/toh-5/dart/lib/app_component.dart
而且当我转到根目录时,我的应用程序似乎正在路由.
本地主机:8080 /
当我在我的应用程序中移动时路由更新,但似乎如果我在某个东西: localhost:8080/dashboard在一个basecase中,并进行硬刷新,它失败了.它会给我一个404 not found!错误.
如果我这样做它会工作:localhost:8080/#!/dashboard但这不是传递给我的应用程序的地址.
在index.html我有: <base href="/">
我的App_Component.dart文件如下:
import 'package:angular2/angular2.dart';
import 'package:angular2/router.dart';
import 'hero_component.dart';
import 'heroes_component.dart';
import 'dashboard_component.dart';
import 'hero_service.dart';
@Component(
selector: "my-app",
directives: const [ROUTER_DIRECTIVES],
providers: const [HeroService, ROUTER_PROVIDERS],
templateUrl: "app_component.html")
@RouteConfig(const [
const Route(
path: "/dashboard",
name: "Dashboard",
component: DashboardComponent,
useAsDefault: true),
const Route(
path: "/detail/:id", name: "HeroDetail", component: HeroDetailComponent),
const Route(path: "/heroes", name: "Heroes", component: HeroesComponent)
])
class AppComponent {
String title = "Tour …Run Code Online (Sandbox Code Playgroud) 我只是在阅读 AngularDart路由教程并遇到了这个代码片段。
import 'package:angular/angular.dart';
import 'package:angular_router/angular_router.dart';
import 'route_paths.dart' as paths;
import 'crisis_list_component.template.dart' as clct;
import 'hero_list_component.template.dart' as hlct;
@Injectable()
class Routes {
static final _crises = new RouteDefinition(
routePath: paths.crises,
component: clct.CrisisListComponentNgFactory,
);
static final _heroes = new RouteDefinition(
routePath: paths.heroes,
component: hlct.HeroListComponentNgFactory,
); ..... see routing tutorial link above.
}
Run Code Online (Sandbox Code Playgroud)
有什么作用
import 'crisis_list_component.template.dart' as clct;
import 'hero_list_component.template.dart' as hlct;
Run Code Online (Sandbox Code Playgroud)
实际导入?
运行webdev serve并尝试调试错误时。我没有看到任何.js.map用于调试的dart 源代码或文件。
可能有什么问题?这是一个使用最新 Dart 2 的全新 angulardart 项目,并且webdev 0.2.4
如果我有一个枚举,例如:
@Component(...)
class MyComponent {
MyEnum myEnum;
...
}
Run Code Online (Sandbox Code Playgroud)
如何在模板中使用此枚举?例如
<div *ngIf="myEnum == MyEnum.SOME_OPTION">
...
</div>
Run Code Online (Sandbox Code Playgroud)
编辑:我对如何使用枚举进行比较特别感兴趣。
“我正在转向使用新语言来创建跨平台应用程序(flutter),但我对创建 Web 应用程序或网站感到困惑,是否可以使用 Dart 和 flutter 进行制作。