@Directive({
selector: 'blurFocus',
//при focus на элемент применяется класс focus
host: {
'(focus)': 'setInputFocus(true)',
'(blur)': 'setInputFocus(false)'
}
})
setInputFocus(isSet: boolean): void {
this.renderer.setElementClass(this.elementRef.nativeElement.parentElement, 'focus', isSet);
}
this.input$ = Observable
.fromEvent(this._el.nativeElement, 'input')
.debounceTime(500);
this.input$.subscribe(event=> this._check(event))
<h2>Эр = {{someVar=(data.Tr * data.k * thr * data.q * data.a * data.b)}}</h2>
<h2>tчр = {{thr = (data.Oi * data.kt / 167 | number : 3) }} руб.</h2>эта переменная учитывает округление иначе:
h2>tчр = {{thr = (data.Oi * data.kt / 167) | number : 3 }}
var httpFactory = {},
cache = $cacheFactory.get('$http');
httpFactory.getInterest = function () {
return getWithCache('ref/user-interest')
};
function getWithCache (url) {
var mycache = httpFactory.getCache(baseUrl+url);
if(mycache) {
const _mycache = angular.copy(mycache);
var deferred = $q.defer();
deferred.resolve({data:JSON.parse(_mycache[1])});
return deferred.promise
}
else return $http.get(baseUrl+url, {cache: true})
}
var reader = new window.FileReader();
reader.readAsDataURL(blob);
reader.onloadend = function() {
base64data = reader.result;
console.log(base64data );
}
getWithCache(url, key, forceRefresh?:boolean):any {
if (!this[key]) {
this[key] = new ReplaySubject(1)
}
// If the Subject was NOT subscribed before OR if forceRefresh is requested
if (!this[key].observers.length || forceRefresh) {
this.get(url).subscribe(
(data) => this[key].next(data),
(error) => {
this[key].error(error);
// Recreate the Observable as after Error we cannot emit data anymore
this[key] = new ReplaySubject(1);
}
);
}
return this[key];
}