function validateInSequence(
...validators: ( (formControl: FormControl) => any )[]
): (formControl: FormControl) => any {
return function (formControl: FormControl): any {
for (let i = 0; i < validators.length; i++) {
const validationResult = validators[i](formControl);
if (validationResult !== null) {
return validationResult;
}
}
return null;
};
}
new FormControl('', [validateInSequence(Validators.required, Validators.email)]);
<a [routerLink]="..." [queryParams]="{category: item}" ... > ... </a>
let declarations = [SomeComponent];
if (!environment.production) {
const devDeclarations = [/*ваши дев компоненты*/];
declarations = declarations.concat(devDeclarations); // равносильно [...declarations, ...devDeclarations]
}
@NgModule({
declarations,
/*...*/
})
export class SomeModuleClass {}
window.open('https://google.com', null, 'menubar=off,toolbar=off')
function someFunction<T>(): T {
return new T();
}
return this.http
.get<Person>("http://test/api/v1/person/view", config)
.map(p => new Person(p));
class SomeComponent {
private _isBlocked$$: Subject<boolean> = new Subject();
public isBlocked$: Observable<boolean> = this._isBlocked$$.asObservable();
public ngOnInit(): void {
this.isBlocked$
.switchMap((isBlocked: boolean) =>
isBlocked ? this.http.post(apiPath) : Observable.of(null))
.subscribe((data: Array<any>) => {
if (data !== null) {
this.notise = this.mapData(data);
}
});
}
public someMethod(bool: boolean): void {
this._isBlocked$$.next(bool);
}
}
Observable.timer(0, 2000).takeUntil(this.isBlocked$)
data.forEach(async (message) => {
if (!message.pinned) {
await message.delete().catch(writeErr); //message.delete - возвращает Promise
}
});
private ngUnsubscribe: Subject<void> = new Subject<void>();
, cледовательно ничего кроме "пустого" значения передать в .next() компилятор тайпскрипта и не разрешит.The Observer callback to receive a valueless notification of type complete from the Observable. Notifies the Observer that the Observable has finished sending push-based notifications.
var moment = require('moment');
var day = moment("Wed Dec 20 2017 13:43:03 GMT+0300");
$('.js-menu-trigger').click(function() {
const header = $('.header');
const headerClass = 'header_colored';
header[header.hasClass(headerClass) ? 'removeClass' : 'addClass'](headerClass);
});
new Schema({
id: {
type: Number,
unique: true,
validate: {
validator: value => typeof value === 'number',
message: 'Invalid id type'
},
}
});
const obs = Observable.timer(0, 3000);
obs.subscribe(i => console.log(i));
obs.subscribe(i => console.log('tick', i));
var autoprefixer = require('gulp-autoprefixer');
var config = ... // ваш конфиг для автопрефиксера
...
gulp.task('sass', function(){
return gulp.src(['app/sass/**/*.sass', 'app/sass/**/*.scss'])
.pipe(sass({outputStyle: 'expanded'}).on('error', sass.logError))
.pipe(autoprefixer(config))
.pipe(gulp.dest('app/css'))
.pipe(browserSync.reload({stream: true}))
});
...
private _activatedRoute: ActivatedRoute
и private _router: Router
this._activatedRoute.paramMap.subscribe((params: ParamMap) => {
let date: string = params.get('date');
if (/*если дата неправильна*/) {
date = ...; // изменим дату на корректную
this._router.navigate(['/date', date]);
}
})