タグ付けされた質問 「angular」

GoogleのウェブフレームワークであるAngular(AngularJSと混同しないでください)に関する質問。このタグは、個々のバージョンに固有ではないAngularの質問に使用します。古いAngularJS(1.x)Webフレームワークの場合は、angularjsタグを使用します。

12
角度4リアクティブ形式で無効なコントロールを見つける方法
私は以下のようなAngularのリアクティブフォームを持っています: this.AddCustomerForm = this.formBuilder.group({ Firstname: ['', Validators.required], Lastname: ['', Validators.required], Email: ['', Validators.required, Validators.pattern(this.EMAIL_REGEX)], Picture: [''], Username: ['', Validators.required], Password: ['', Validators.required], Address: ['', Validators.required], Postcode: ['', Validators.required], City: ['', Validators.required], Country: ['', Validators.required] }); createCustomer(currentCustomer: Customer) { if (!this.AddCustomerForm.valid) { //some app logic } } this.AddCustomerForm.validはfalseを返しますが、すべてが正常に見えます。 コントロールコレクションのstatusプロパティを確認して見つけようとしました。しかし、無効なものを見つけてユーザーに表示する方法があるのだろうか?


9
Angular2-Http POSTリクエストパラメータ
POSTリクエストを作成しようとしていますが、機能しません。 testRequest() { var body = 'username=myusername?password=mypassword'; var headers = new Headers(); headers.append('Content-Type', 'application/x-www-form-urlencoded'); this.http .post('/api', body, { headers: headers }) .subscribe(data => { alert('ok'); }, error => { console.log(JSON.stringify(error.json())); }); } 私は基本的に、このHTTPリクエスト(ajaxではありません)をHTMLフォームによって作成されたように複製したいと思います。 URL:/ api パラメータ:ユーザー名とパスワード

4
ngForと非同期パイプAngular 2で監視可能なオブジェクトの配列を使用する
Angular 2でObservablesを使用する方法を理解しようとしています。このサービスがあります: import {Injectable, EventEmitter, ViewChild} from '@angular/core'; import {Observable} from "rxjs/Observable"; import {Subject} from "rxjs/Subject"; import {BehaviorSubject} from "rxjs/Rx"; import {Availabilities} from './availabilities-interface' @Injectable() export class AppointmentChoiceStore { public _appointmentChoices: BehaviorSubject<Availabilities> = new BehaviorSubject<Availabilities>({"availabilities": [''], "length": 0}) constructor() {} getAppointments() { return this.asObservable(this._appointmentChoices) } asObservable(subject: Subject<any>) { return new …

6
2つのオブジェクト配列をAngular2とTypeScriptでマージしますか?
私はこのトピックに関するJavaScriptの質問に出くわしました。この質問は、特にTypeScriptを使用したAngular2に関するものです。 私がやろうとしているのは、jsonオブジェクトを配列に連結することです。 私のコードは次のようになります、 public results: []; public getResults(){ this._service.get_search_results(this._slug, this._next).subscribe( data => { this.results.concat(data.results); this._next = data.next; }, err => { console.log(err); } ); } どのようにして連結することができますdata.resultsにthis.resultstypescriptですし、角度と? this._slugとthis._nextクラスに設定されています。 ありがとう。

5
Angular2は要素の既知のプロパティではないため、DIRECTIVEにバインドできません
Angular CLIによって新しい@Directiveを生成し、それをapp.module.tsにインポートしました import { ContenteditableModelDirective } from './directives/contenteditable-model.directive'; import { ChatWindowComponent } from './chat-window/chat-window.component'; @NgModule({ declarations: [ AppComponent, ContenteditableModelDirective, ChatWindowComponent, ... ], imports: [ ... ], ... }) コンポーネント(ChatWindowComponent)で使用しようとしています <p [appContenteditableModel] > Write message </p> ディレクティブ内がAngularCLIで生成されたコードのみである場合でも: import { Directive } from '@angular/core'; @Directive({ selector: '[appContenteditableModel]' }) export class ContenteditableModelDirective { …

3
角度2で同等のonchange
入力範囲の値をfirebaseに保存するためにonchangeを使用していますが、関数が定義されていないというエラーが発生します。 これが私の機能です saverange(){ this.Platform.ready().then(() => { this.rootRef.child("users").child(this.UserID).child('range').set(this.range) }) } これは私のhtmlです <ion-item> <ion-row> <ion-col>Rayon <span favorite><strong> {{range}} km</strong></span></ion-col> <ion-col><input type="range" name="points" min="0" max="40" [(ngModel)]="range" onchange="saverange()"></ion-col> </ion-row> </ion-item> 存在する場合、角度のオンチェンジに相当するものは何ですか。ありがとうございました
91 angular 

3
'div'の既知のプロパティではないため、 'aria-valuenow'にバインドできません
次のコードの何が問題になっていますか?要素に式を割り当てようとしたときに私に起こりました、 <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="{{MY_PREC}}" aria-valuemin="0" aria-valuemax="100" > {{MY_PREC}} </div> また、 [aria-valuenow]={{MY_PREC}} RC5以降に発生しているようです 何か案は?
91 angular 

4
Angular cli-ngserve時に自動リロードを無効にする方法
Angular cliを使用してアプリを提供する場合、自動リロードを無効にするにはどうすればよいですか? ng --help--live-reloadオプションについて言及していますが、私はそれを機能させることができません。 ng serve --live-reload=falseまたは動作ng serve --live-reload falseしない 編集:それはバグのようですhttps://github.com/angular/angular-cli/issues/1755

4
FormGroupとFormArrayをいつ使用するのですか?
FormGroup: A FormGroupはキーとして各コントロール名と、1つのオブジェクトに各子FormControlの値を集約します。 const form = new FormGroup({ first: new FormControl('Nancy', Validators.minLength(2)), last: new FormControl('Drew') }); FormArray: A FormArrayは配列に各子FormControlの値を集約します。 const arr = new FormArray([ new FormControl('Nancy', Validators.minLength(2)), new FormControl('Drew') ]); いつ一方を他方の上に使用する必要がありますか?

7
formGroupのAngular2設定値
そのため、エンティティを作成するための複雑なフォームがあり、それを編集にも使用したいと思います。新しい角度フォームAPIを使用しています。データベースから取得したデータとまったく同じようにフォームを構造化したので、フォーム全体の値をここで取得したデータに設定したいのは、私がやりたいことの例です。 this.form = builder.group({ b : [ "", Validators.required ], c : [ "", Validators.required ], d : [ "" ], e : [ [] ], f : [ "" ] }); this.form.value({b:"data",c:"data",d:"data",e:["data1","data2"],f:data}); PS:NgModelは新しいフォームAPIでは機能しません。また、テンプレートで一方向のデータバインディングを使用してもかまいません。 <input formControlName="d" value="[data.d]" /> それは機能しますが、アレイの場合は面倒です

8
Angularで401をグローバルに処理する
私のAngular 2プロジェクトでは、Observableを返すサービスからAPI呼び出しを行います。次に、呼び出しコードはこのオブザーバブルをサブスクライブします。例えば: getCampaigns(): Observable<Campaign[]> { return this.http.get('/campaigns').map(res => res.json()); } サーバーが401を返すとしましょう。このエラーをグローバルにキャッチして、ログインページ/コンポーネントにリダイレクトするにはどうすればよいですか? ありがとう。 ここに私がこれまで持っているものがあります: // boot.ts import {Http, XHRBackend, RequestOptions} from 'angular2/http'; import {CustomHttp} from './customhttp'; bootstrap(AppComponent, [HTTP_PROVIDERS, ROUTER_PROVIDERS, new Provider(Http, { useFactory: (backend: XHRBackend, defaultOptions: RequestOptions) => new CustomHttp(backend, defaultOptions), deps: [XHRBackend, RequestOptions] }) ]); // customhttp.ts import {Http, ConnectionBackend, …
90 angular 

5
Angular 2なぜアスタリスク(*)
Angular 2ドキュメント*およびテンプレートでは、* ngIf、* ngSwitch、* ngForをng-templateタグに展開できることがわかっています。私の質問は: 私が考えるngIfかngForなし*にも翻訳され、角度のエンジンによってテンプレートタグに拡張することができます。 次のコード <hero-detail *ngIf="currentHero" [hero]="currentHero"></hero-detail> と同じになります <ng-template [ngIf]="currentHero"> <hero-detail [hero]="currentHero"></hero-detail> </ng-template> では、なぜ*角度2で奇妙な記号アスタリスク()をわざわざ設計するのでしょうか。

5
角度4ユニットテストエラー `TypeError:ctorはコンストラクターではありません`
ルートリゾルバーをテストしようとしていますが、テスト中にTypeError: ctor is not a constructor、typescriptのコンパイル時にエラーが発生しない理由がわかりません。 TypeError: ctor is not a constructor TypeError: ctor is not a constructor at _createClass (http://localhost:9877/_karma_webpack_/vendor.bundle.js:42355:26) at _createProviderInstance$1 (http://localhost:9877/_karma_webpack_/vendor.bundle.js:42330:26) at resolveNgModuleDep (http://localhost:9877/_karma_webpack_/vendor.bundle.js:42315:17) at _createClass (http://localhost:9877/_karma_webpack_/vendor.bundle.js:42362:26) at _createProviderInstance$1 (http://localhost:9877/_karma_webpack_/vendor.bundle.js:42330:26) at resolveNgModuleDep (http://localhost:9877/_karma_webpack_/vendor.bundle.js:42315:17) at NgModuleRef_.webpackJsonp../node_modules/@angular/core/@angular/core.es5.js.NgModuleRef_.get (http://localhost:9877/_karma_webpack_/vendor.bundle.js:43401:16) at TestBed.webpackJsonp../node_modules/@angular/core/@angular/core/testing.es5.js.TestBed.get (http://localhost:9877/_karma_webpack_/vendor.bundle.js:48412:47) at http://localhost:9877/_karma_webpack_/vendor.bundle.js:48418:61 at Array.map (native)

13
Angular 2で入力タグファイルタイプで選択したファイルをリセットするにはどうすればよいですか?
これは私の入力タグがどのように見えるかです: <input type="file" placeholder="File Name" name="filename" (change)="onChange($event)"> <button>Reset</button> 選択したファイルをAngular2でリセットしたいのですが。助けていただければ幸いです。詳細が必要な場合はお知らせください。 PS $eventパラメータからファイルの詳細を取得してtypescript変数に保存できましたが、この変数は入力タグにバインドされていません。
90 angular 

弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.