我有2个单选按钮,我正在使用反应式表单,我在组件中添加了表单控件.我面临的问题是name属性必须与formControlName相同.当我将name属性设置为相同时,我只能选择1个单选按钮 - 永远不能取消选择并选择另一个.只允许我选择同一个.
this.genderControl = new FormControl("", Validators.required);
Run Code Online (Sandbox Code Playgroud)
然后添加到我的表格组
genderControl: this.genderControl,
Run Code Online (Sandbox Code Playgroud)
我的HTML:
<div class="radio-inline">
<input id="gender" type="radio" name="genderControl" formControlName="genderControl" />
<label class="radio-label"> Male</label>
<input id="gender" type="radio" name="genderControl" formControlName="genderControl" />
<label class="radio-label">Female</label>
</div>
Run Code Online (Sandbox Code Playgroud)
表格组
this.personalInfo = new FormGroup({
searchControl: this.searchControl,
titleControl: this.titleControl,
firstNameControl: this.firstNameControl,
middleNameControl: this.middleNameControl,
lastNameControl: this.lastNameControl,
birthdayControl: this.birthdayControl,
genderControl: this.genderControl,
phoneControl: this.phoneControl,
taxCanadaControl: this.taxCanadaControl,
provinceControl: this.provinceControl,
countryControl: this.countryControl,
taxCountryControl: this.taxCountryControl,
creditControl: this.creditControl
});
Run Code Online (Sandbox Code Playgroud) 嘿,寻求一些见识,
因此,我以前从未使用过Ionic,并试图给自己一个使用它的理由。但是,根据我一直在阅读的内容-根据项目的用例,一个可能比另一个更合适。我正在尝试构建不使用许多本机功能的应用程序。因此,我想知道Angular6 / MD + PWA是否会是更好的方法,我是否仍然可以使用相机和地理定位等功能而不使用离子系统?如果我走angular6 / MD路线,是否需要使用科尔多瓦之类的东西?
如果我想在应用程序商店等上发布应用程序并利用更多本机功能,我假设使用ionic?
在执行ng test之后,我的测试跑步者开始执行所有测试,但之后就一片空白。参见下图。
我的业力配置:
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma')
],
client:{
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
files: [
{ pattern: './src/test.ts', watched: false }
],
preprocessors: {
'./src/test.ts': ['@angular/cli']
},
mime: {
'text/x-typescript': ['ts','tsx']
},
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'coverage-istanbul']
: ['progress', 'kjhtml'],
port: …Run Code Online (Sandbox Code Playgroud) 我正在我的角度项目中实施CSRF保护.我已升级到4.3,并根据HttpClientModule文档:
https://angular.io/guide/http#security-xsrf-protection
我必须实施,
HttpClientXsrfModule.withConfig({
cookieName: 'My-Xsrf-Cookie',
headerName: 'My-Xsrf-Header',
}),
Run Code Online (Sandbox Code Playgroud)
我已经这样做了,但是编译器抱怨:
类型'typeof HttpClientXsrfModule'上不存在属性'withConfig'.
我在我的应用程序/组件中使用lodash。茉莉花抱怨:
失败:无法读取未定义的属性“ eq”
我已将lodash添加到我的karma.conf中
例如:{模式:'./ node_modules / lodash / lodash.min.js',包括:true,观看次数:false}
仍然存在问题,包括lodash的正确方法是什么?
我有 20 个复选框,我需要能够将选中的复选框数量限制为 5/20。根据选中的复选框,它应该隐藏/显示标签。
选中 5 后,不应再选中,而在取消选中 5 或任何后续选中时,它应该允许我再次选中一个不同的框,直到 5 的限制。
我的复选框是使用 angular 指令 *ngFor 生成的,并且会有 5 个答案,因此开始时有 5 个检查。
<div *ngFor="let question of questions; let i = index" class="row container-generic">
<div class="col-md-8">
<div class="container-input-checkbox">
<label class="container-flex">
<input #checkBox class="pvq-create-checkbox" type="checkbox" name="{{i}}" (change)="checkedState($event, checkBox)" [checked]="question.answer">
<div class="pvq-create-label">
<div *ngIf="lang == 'en'">
<p>{{ question.question_EN }}</p>
</div>
<div *ngIf="lang == 'fr'">
<p>{{ question.question_FR }}</p>
</div>
</div>
</label>
<label [@hideShow]="checkBox.checked ? 'show' : 'hide'" >Answer
<input type="textbox" name="" placeholder="{{ question.answer }}">
</label>
</div> …Run Code Online (Sandbox Code Playgroud)