小编max*_*der的帖子

棱角2为什么星号(*)

在angular 2文档,*和模板中,我们知道*ngIf,*ngSwitch,*ngFor可以扩展为模板标记.我的问题是:

我觉得ngIf还是ngFor没有*也可以翻译并通过角引擎扩展到模板标签.那么为什么要*在角度2中设计一个奇怪的符号asterisk()呢?

<hero-detail *ngIf="currentHero" [hero]="currentHero"></hero-detail>
Run Code Online (Sandbox Code Playgroud)
<template [ngIf]="currentHero">
  <hero-detail [hero]="currentHero"></hero-detail>
</template>
Run Code Online (Sandbox Code Playgroud)

javascript angular

80
推荐指数
3
解决办法
2万
查看次数

为什么angular 2 provider {useValue:...}克隆对象?

Angular 2高级测试文档:

userServiceStub = {
  isLoggedIn: true,
  user: { name: 'Test User'}
};

TestBed.configureTestingModule({
   declarations: [ WelcomeComponent ],
// providers:    [ UserService ]  // NO! Don't provide the real service!
                                  // Provide a test-double instead
   providers:    [ {provide: UserService, useValue: userServiceStub } ]
});

fixture = TestBed.createComponent(WelcomeComponent);
comp    = fixture.componentInstance;

// UserService actually injected into the component
userService = fixture.debugElement.injector.get(UserService);
componentUserService = userService;
// UserService from the root injector
userService = TestBed.get(UserService);
Run Code Online (Sandbox Code Playgroud)

看来我们显式创建的服务,userService表单injector.get()和userServiceStub是不同的Object.

it('stub object and injected UserService should not …
Run Code Online (Sandbox Code Playgroud)

javascript typescript angular

10
推荐指数
1
解决办法
1035
查看次数

css @import和SASS/SCSS @import有什么区别?

原始css有@import关键字,可以包含外部css文件.

那么,来自SASS/SCSS @import的这个@import有什么区别?

css sass

6
推荐指数
2
解决办法
2724
查看次数

为什么@angular表单中没有FormArrayDirective?

根据角度的最新版本,@ angular/forms导出以下内容:

export {FormControlDirective} from './directives/reactive_directives/form_control_directive';
export {FormControlName} from './directives/reactive_directives/form_control_name';
export {FormGroupDirective} from './directives/reactive_directives/form_group_directive';
export {FormArrayName} from './directives/reactive_directives/form_group_name';
export {FormGroupName} from './directives/reactive_directives/form_group_name';
Run Code Online (Sandbox Code Playgroud)

FormContolName并且FormControlDirective,FormGroupNameFormGroupDirective,但FormArrayName没有FormArrayDirective,为什么?

javascript angular2-forms angular angular4-forms

5
推荐指数
1
解决办法
152
查看次数

html标签中百分号表达式的含义是什么?

我在 angular2-seed 中发现了一些奇怪的符号 <%%>,<%%> 是干什么用的?

https://github.com/AngularClass/angular2-webpack-starter/blob/master/src/index.html

<!DOCTYPE html>
<html lang="">
<head>
  <meta charset="utf-8">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <title><%= htmlWebpackPlugin.options.title %></title>

  <meta name="description" content="<%= htmlWebpackPlugin.options.title %>">

  <% if (webpackConfig.htmlElements.headTags) { %>
  <!-- Configured Head Tags  -->
  <%= webpackConfig.htmlElements.headTags %>
  <% } %>

  <!-- base url -->
  <base href="<%= htmlWebpackPlugin.options.metadata.baseUrl %>">


</head>

<body>

  <app>
    Loading...
  </app>

 .....

  <% if (htmlWebpackPlugin.options.metadata.isDevServer && htmlWebpackPlugin.options.metadata.HMR !== true) { %>
  <!-- Webpack Dev Server reload -->
  <script src="/webpack-dev-server.js"></script>
  <% } %>


</body>
</html>
Run Code Online (Sandbox Code Playgroud)

html javascript

3
推荐指数
2
解决办法
5546
查看次数