{"id":296184,"date":"2019-12-21T15:00:20","date_gmt":"2019-12-21T15:00:20","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=296184"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=296184","title":{"rendered":"\u0421\u0432\u043e\u0438 Custom Controls \u0432 Angular"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/481424\/\">\n<h3>\u041f\u0440\u043e\u043b\u043e\u0433<\/h3>\n<p>  \u041f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0445 \u0432 angular, \u0443\u0437\u043d\u0430\u0435\u043c \u0437\u0430 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044b, \u043a\u0430\u043a \u0438\u0445 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0421\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0447\u0442\u043e \u0432\u044b \u0443\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c angular, \u043d\u043e \u0445\u043e\u0442\u0438\u0442\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f \u0432 \u0435\u0451 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0443. \u0425\u043e\u0440\u043e\u0448\u0435\u0435 \u0436\u0435\u043b\u0430\u043d\u0438\u0435, \u043d\u0430\u0447\u043d\u0435\u043c.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h3>Reactive \u0438 Template Driven\u00a0\u0444\u043e\u0440\u043c\u044b<\/h3>\n<p>  \u041f\u0430\u0440\u0430 \u0441\u043b\u043e\u0432 to be sure we are on the same page. \u0410\u043d\u0433\u0443\u043b\u044f\u0440 \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0430 \u0442\u0438\u043f\u0430 \u0444\u043e\u0440\u043c: <i>Template Driven Forms<\/i> \u0438 <i>Reactive Forms<\/i>.<\/p>\n<p>  <i>Template Driven Forms<\/i> \u044d\u0442\u043e \u0444\u043e\u0440\u043c\u044b \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 <i>two-way binding<\/i> (\u043f\u0440\u0438\u0432\u0435\u0442, angularjs). \u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u0435 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, username), \u0432 html \u0443 \u0442\u0435\u0433\u0430 input \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u043c [(value)]=\u00abusername\u00bb, \u0438 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u043f\u0443\u0442\u0430 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 username. \u0412 2011 \u0433\u043e\u0434\u0443 \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0447\u0435\u0440\u0442\u043e\u0432\u043e\u0439 \u043c\u0430\u0433\u0438\u0435\u0439! \u041e\u043a\u0435\u0439, \u043d\u043e \u0435\u0441\u0442\u044c \u043d\u044e\u0430\u043d\u0441. \u0422\u0430\u043a\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0444\u043e\u0440\u043c\u044b \u0431\u0443\u0434\u0435\u0442\u2026 \u0441\u043b\u043e\u0436\u043d\u043e.<\/p>\n<p>  <i>Reactive Forms<\/i> \u044d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0444\u043e\u0440\u043c. \u041e\u043d\u0438 \u0433\u043e\u0432\u043e\u0440\u044f\u0442 \u043d\u0430\u043c \u00ab\u0441\u043e\u0437\u0434\u0430\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 \u0444\u043e\u0440\u043c\u044b (<i>FormGroup<\/i>), \u043f\u0435\u0440\u0435\u0434\u0430\u0439 \u0435\u043c\u0443 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043e\u0432 (<i>FormControl<\/i>) \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u0434\u0430\u0439 \u044d\u0442\u043e \u0432 html, \u0430 \u044f \u0441\u0434\u0435\u043b\u0430\u044e \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435\u00bb. \u041e\u043a\u0435\u0439, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c:<\/p>\n<pre><code class=\"javascript\">class UsefullComponent {  public control = new FormControl('');  public formG = new FormGroup({username: control}); } <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"xml\">&lt;form [formGroup]=&quot;formG&quot;&gt;  &lt;input type=&quot;text&quot; formControlName=&quot;username&quot;&gt; &lt;\/form&gt; <\/code><\/pre>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443, \u0441 \u0431\u043b\u044d\u043a\u0434\u0436\u0435\u043a\u043e\u043c \u0438\u2026 \u043d\u0443 \u0432\u044b \u043f\u043e\u043d\u044f\u043b\u0438, \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0441\u0442\u044f\u043c\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <i>formG.valueChanges<\/i> \u0434\u0430\u0441\u0442 \u043d\u0430\u043c Observable (\u043f\u043e\u0442\u043e\u043a) \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0444\u043e\u0440\u043c\u044b. \u0422\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044b, \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435, \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438, \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u043e\u0440\u043c\u044b (<i>formG.value<\/i>) \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435. \u0418 \u0432\u0441\u0435 \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044f \u0441 \u043e\u0434\u043d\u0438\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c <i>formG<\/i>.<\/p>\n<p>  \u0410 \u0447\u0442\u043e\u0431\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 angular&#8217;\u0430 \u0434\u0430\u043b\u0438 \u043d\u0430\u043c \u0443\u0434\u043e\u0431\u043d\u044b\u0439 <i>FormBuilder<\/i> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0448\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"javascript\">class UsefullComponent {  public formG: FormGroup;   constructor(private fb: FormBuilder) {   this.formG = fb.group({    name: '' \/\/ \u043d\u0438\u043a\u0430\u043a\u0438\u0445 new FormControl() !!   })  }  } <\/code><\/pre>\n<p>  <\/p>\n<h3>Custom Controls<\/h3>\n<p>  \u0410\u043d\u0433\u0443\u043b\u044f\u0440 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c \u00ab\u0431\u0440\u043e, \u0435\u0441\u043b\u0438 \u0442\u0435\u0431\u0435 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043e\u0432 (input, date, number \u0438 \u0434\u0440\u0443\u0433\u0438\u0435), \u0438\u043b\u0438 \u043e\u043d\u0438 \u0442\u0435\u0431\u0435 \u0432\u0434\u0440\u0443\u0433 \u0447\u0435\u043c \u0442\u043e \u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0438\u0441\u044c, \u0432\u043e\u0442 \u0442\u0435\u0431\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u043d\u043e \u0432 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0447\u0435\u043d\u044c \u043c\u043e\u0449\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0432\u043e\u0438\u0445\u00bb. \u041a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044b \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0445\u043e\u0442\u044c \u0441 \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c\u0438, \u0445\u043e\u0442\u044c \u0441 template-driven \u0444\u043e\u0440\u043c\u0430\u043c\u0438, \u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u043e\u043d\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432 (\u0443\u0434\u0438\u0432\u0438\u043b\u0438!). \u0417\u043d\u0430\u044f \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u044d\u0442\u043e \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b \u0441 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c (\u0442\u043e \u0447\u0442\u043e \u043d\u0430\u0434\u043e), \u043d\u0430\u043f\u0438\u0448\u0435\u043c:<\/p>\n<pre><code class=\"javascript\">import { Component, Input } from '@angular\/core';  @Component({  selector: 'counter-control',  template: `   &lt;button (click)=&quot;down()&quot;&gt;Down&lt;\/button&gt;    {{ value }}   &lt;button (click)=&quot;up()&quot;&gt;Up&lt;\/button&gt;  ` }) class CounterControlComponent {   @Input()   value = 0;    up() {   this.value++;  }    down() {   this.value - ;  } } <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0438 \u043b\u044e\u0431\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0443, \u044d\u0442\u0443 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0434\u0435\u043a\u043b\u0430\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u043c\u043e\u0434\u0443\u043b\u0435 (\u0447\u0442\u043e\u0431\u044b \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0435 \u0440\u0430\u0437\u0440\u0430\u0441\u0442\u0430\u043b\u0430\u0441\u044c, \u0442\u0430\u043a\u0438\u0435 \u043d\u044e\u0430\u043d\u0441\u044b \u043e\u043f\u0443\u0441\u0442\u0438\u043c).<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443:<\/p>\n<pre><code class=\"javascript\">import { Component } from '@angular\/core';  @Component({  selector: 'parent-component',  template: `   &lt;counter-control&gt;&lt;\/counter-control&gt;  ` }) class ParentComponent {} <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0432\u0441\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e \u0433\u0434\u0435 \u0444\u043e\u0440\u043c\u044b?! \u0425\u043e\u0442\u044f \u0431\u044b template-driven\u2026.<br \/>  \u0411\u0435\u0437 \u043f\u0430\u043d\u0438\u043a\u0438, \u0432\u0441\u0435 \u0431\u0443\u0434\u0435\u0442, \u043f\u043e\u0441\u043b\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0430 \u0441 <i>ControlValueAccessor<\/i>.<\/p>\n<h3>Control Value\u00a0Accessor<\/h3>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b angular&#8217;\u0430 \u043c\u043e\u0433\u043b\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u0432\u0430\u0448\u0438\u043c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043e\u043c, \u043d\u0443\u0436\u043d\u043e \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0442 \u043a\u043e\u043d\u0442\u0440\u043e\u043b \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. \u042d\u0442\u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <i>ControlValueAccessor<\/i>. \u042d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c\u0430 \u0438\u0437 \u041e\u041e\u041f, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0448 \u043e\u0431\u044a\u0435\u043a\u0442 (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u043d\u0442\u0440\u043e\u043b) \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b (\u0444\u043e\u0440\u043c\u044b \u0430\u043d\u0433\u0443\u043b\u044f\u0440\u0430) \u0447\u0435\u0440\u0435\u0437 \u044d\u0442\u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0442 \u0441 \u043d\u0430\u0448\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c.<\/p>\n<p>  \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f <i>ControlValueAccessor<\/i> \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0435\u0434\u0438\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043a\u0441\u0442\u0430\u0442\u0438 \u0433\u043e\u0432\u043e\u0440\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043e\u0432. Angular \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0442\u0430\u043a \u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u044d\u0442\u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. \u0414\u043b\u044f \u0447\u0435\u0433\u043e? \u0410 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043b\u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043a \u0435\u0434\u0438\u043d\u043e\u043c\u0443 \u0432\u0438\u0434\u0443 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443 input \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0435 value, \u0443 \u0447\u0435\u043a\u0431\u043e\u043a\u0441\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 checked. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043e\u0432 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0439 ControlValueAccessor: <i>DefaultValueAccessor<\/i>\u200a-\u200a\u0434\u043b\u044f input&#8217;\u043e\u0432 \u0438 textarea, <i>CheckboxControlValueAccessor<\/i>\u200a-\u200a\u0434\u043b\u044f \u0447\u0435\u043a\u0431\u043e\u043a\u0441\u043e\u0432, <i>RadioControlValueAccessor<\/i> \u0434\u043b\u044f \u0440\u0430\u0434\u0438\u043e\u043a\u043d\u043e\u043f\u043e\u043a \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<\/p>\n<p>  \u041d\u043e \u0447\u0442\u043e angular \u0434\u0435\u043b\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <i>ControlValueAccessor<\/i>? \u0412\u0441\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 DOM (view), \u0430 \u0442\u0430\u043a \u0436\u0435 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0430 \u0434\u043e <i>FormGroup<\/i> \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0443\u0437\u043d\u0430\u043b\u0438 \u043f\u0440\u043e <i>ControlValueAccessor<\/i>, \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0443.<\/p>\n<p>  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441:<\/p>\n<pre><code class=\"javascript\">interface ControlValueAccessor {   writeValue(value: any): void   registerOnChange(fn: any): void   registerOnTouched(fn: any): void } <\/code><\/pre>\n<p>  <i>writeValue(value: any)<\/i> \u2014 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e (<i>new FormControl(&#8216;I am default value&#8217;)<\/i>) \u0438\u043b\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u0432\u0435\u0440\u0445\u0443 <i>control.setValue(&#8216;I am setted value&#8217;)<\/i>.<\/p>\n<p>  <i>registerOnChange(fn: any)<\/i> \u2014 \u043c\u0435\u0442\u043e\u0434 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432\u044b\u0437\u0432\u0430\u043d \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f (fn \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f callback&#8217;\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0432\u0435\u0434\u043e\u043c\u0438\u0442 \u0444\u043e\u0440\u043c\u0443 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435).<\/p>\n<p>  <i>registerOnTouched(fn: any)\u200a<\/i> \u2014 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e registerOnChange, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 touch-\u0441\u043e\u0431\u044b\u0442\u0438\u044f<\/p>\n<pre><code class=\"javascript\">import { Component, Input } from '@angular\/core'; import { ControlValueAccessor } from '@angular\/forms';  @Component({  selector: 'counter-control',  template: `   &lt;button (click)=&quot;down()&quot;&gt;Down&lt;\/button&gt;    {{ value }}   &lt;button (click)=&quot;up()&quot;&gt;Up&lt;\/button&gt;  ` }) class CounterControlComponent implements ControlValueAccessor {  @Input()  value = 0;   onChange(_: any) {}   up() {   this.value++;  }   down() {   this.value - ;  }   writeValue(value: any) {   this.value = value;  }   registerOnChange(fn) {   this.onChange = fn;  }   registerOnTouched() {} } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f \u0444\u043e\u0440\u043c\u0430 \u0437\u043d\u0430\u043b\u0430 \u043e\u0431 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0430, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <i>onChange<\/i> \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f value. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432 <i>onChange<\/i> \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 (up \u0438 down), \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u043e\u043b\u0435 value \u0447\u0435\u0440\u0435\u0437 \u0433\u0435\u0442\u0442\u0435\u0440\u044b \u0438 \u0441\u0435\u0442\u0442\u0435\u0440\u044b:<\/p>\n<pre><code class=\"javascript\">\/\/ \u2026 class CounterControlComponent implements ControlValueAccessor {  private _value;   get value() {   return this._value;  }   @Input()  set value(val) {   this._value = val;   this.onChange(this._value);  }   onChange(_: any) {}    up() {   this.value++;  }    down() {   this.value - ;  }  \/\/ \u2026 } <\/code><\/pre>\n<p>  \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0430\u043d\u0433\u0443\u043b\u044f\u0440 \u043d\u0435 \u043a\u0443\u0440\u0441\u0435, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 <i>ControlValueAccessor<\/i> \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b, \u0441\u043a\u0430\u0436\u0435\u043c \u0435\u043c\u0443 \u043e\u0431 \u044d\u0442\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">import { Component, Input, forwardRef } from '@angular\/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular\/forms';  @Component({  \u2026  providers: [{    provide: NG_VALUE_ACCESSOR,   useExisting: forwardRef(() =&gt; CounterControlComponent),   multi: true  }] }) class CounterControlComponent implements ControlValueAccessor {  \u2026 } <\/code><\/pre>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0443\u0447\u0430\u0441\u0442\u043a\u0435 \u043a\u043e\u0434\u0430 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0430\u043d\u0433\u0443\u043b\u044f\u0440\u0443 \u00ab\u044f \u0445\u043e\u0447\u0443 \u0437\u0430\u0440\u0435\u0433\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b (<i>provide: NG_VALUE_ACCESSOR<\/i>), \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439 \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 (\u043d\u0430 \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u0448\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439) \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b (<i>useExisting: forwardRef(() =&gt; CounterControlComponent)<\/i>)\u00bb.\u00a0<\/p>\n<p>  <i>multi: true<\/i> \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c \u0447\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0441 \u0442\u0430\u043a\u0438\u043c \u0442\u043e\u043a\u0435\u043d\u043e\u043c (<i>NG_VALUE_ACCESSOR<\/i>) \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e.<\/p>\n<h3>\u041d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0436 \u0442\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0438<\/h3>\n<p>  \u0421\u0430\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u044e\u0437\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b. \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <i>FormsModule \/ ReactiveFormsModule <\/i>\u0432 \u0438\u043c\u043f\u043e\u0440\u0442\u044b \u043c\u043e\u0434\u0443\u043b\u044f \u0433\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u044d\u0442\u043e\u0442 \u043a\u043e\u043d\u0442\u0440\u043e\u043b.<\/p>\n<h4>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 Template Driven\u00a0\u0444\u043e\u0440\u043c\u0430\u0445<\/h4>\n<p>  \u0422\u0443\u0442 \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u0432\u0443\u0445\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0435 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 <i>ngModel<\/i> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 view \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442:<\/p>\n<pre><code class=\"javascript\">import { Component } from '@angular\/core';  @Component({  selector: 'parent-component',  template: `   &lt;counter-control [(ngModel)]=&quot;controlValue&quot;&gt;&lt;\/counter-control&gt;  ` }) class ParentComponent {  controlValue = 10; } <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 Reactive\u00a0Forms<\/h4>\n<p>  \u041a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u044b \u0447\u0435\u0440\u0435\u0437 <i>FormBuilder<\/i>, \u043e\u0442\u0434\u0430\u0435\u043c \u0432 html \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435:<\/p>\n<pre><code class=\"javascript\">import { Component, OnInit } from '@angular\/core'; import { FormBuilder } from '@angular\/forms';  @Component({  selector: 'parent-component',  template: `   &lt;form [formGroup]=&quot;form&quot;&gt;    &lt;counter-control formControlName=&quot;counter&quot;&gt;&lt;\/counter-control&gt;   &lt;\/form&gt;  ` }) class ParentComponent implements OnInit {  form: FormGroup;   constructor(private fb: FormBuilder) {}   ngOnInit() {   this.form = this.fb.group({    counter: 5   });  } } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u0444\u043e\u0440\u043c\u0430 \u0441 \u043d\u0430\u0448\u0438\u043c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043e\u043c, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0441\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0442\u0430\u043a\u0436\u0435, \u043a\u0430\u043a \u0438 \u0441 \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0430\u043c\u0438 (\u044f \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b \u043f\u0440\u043e \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c?). \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043d\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e, \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0437\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043e\u0432 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>  \u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b:<\/p>\n<p>  <a href=\"https:\/\/blog.thoughtram.io\/angular\/2016\/07\/27\/custom-form-controls-in-angular-2.html\">\u0421\u0442\u0430\u0442\u044c\u044f<\/a> \u043e \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0430\u0445 \u043e\u0442 Pascal Precht.<br \/>  <a href=\"https:\/\/angular.io\/guide\/forms-overview\">\u041e\u0444 \u0434\u043e\u043a\u0438<\/a> \u0444\u043e\u0440\u043c \u0432 \u0430\u043d\u0433\u0443\u043b\u044f\u0440\u0435.<br \/>  <a href=\"https:\/\/habr.com\/ru\/post\/438642\/\">\u0421\u0435\u0440\u0438\u044f \u0441\u0442\u0430\u0442\u0435\u0439<\/a> \u043e rxjs.<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d() } } }t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>      <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/481424\/\"> https:\/\/habr.com\/ru\/post\/481424\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/481424\/\">\n<h3>\u041f\u0440\u043e\u043b\u043e\u0433<\/h3>\n<p>  \u041f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0445 \u0432 angular, \u0443\u0437\u043d\u0430\u0435\u043c \u0437\u0430 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044b, \u043a\u0430\u043a \u0438\u0445 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0421\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0447\u0442\u043e \u0432\u044b \u0443\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c angular, \u043d\u043e \u0445\u043e\u0442\u0438\u0442\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f \u0432 \u0435\u0451 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0443. \u0425\u043e\u0440\u043e\u0448\u0435\u0435 \u0436\u0435\u043b\u0430\u043d\u0438\u0435, \u043d\u0430\u0447\u043d\u0435\u043c.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-296184","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296184","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=296184"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296184\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=296184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=296184"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=296184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}