var template = $templateCache.get('nameOfTemplate.html');
var scope = {
var1: 'Переменная в шаблон',
someEvent: function() {
alert('Событие из шаблона')
}
}
var compiledContent = $compile(template)(scope)
element.append(compiledContent)
buildMarkers(cars): void {
return Observable.create(observer => {
for (let i in cars) {
let lat: number = cars[i].coordinates.lat;
let lon: number = cars[i].coordinates.lon;
let pin = cars[i].pin;
let singleMarker = new Marker([lat, lon], {
icon: new DivIcon({
className: 'my-div-icon',
html: this.getHtmlMarker(cars, pin)
})
});
this.layers.push(singleMarker);
};
observer.next();
observer.complete()
});
};
public mapReady(map) {
this.map = map;
let that = this;
that.buildMarkers(this.cars).subscribe(() => {
// тут выполните код, который гарантированно выполнится после buildMarkers
});
};
<div id="calendar"></div>
а станет так <div my-calendar></div>
function Directive () {
return {
restrict: 'A',
link: link
};
function link (scope, element) {
element.fullCalendar();
}
}
angular
.module('app.shared')
.directive('my-calendar', Directive);
document.on('mousewheel DOMMouseScroll scroll', (event) => {
const docHeight = document.height;
const height = window.height;
const offsetY = Math.round(window.scrollTop());
// todo
});
[Injectable]
class ScrollService {
public onScroll$ = new Subject();
constructor() {
document.on('mousewheel DOMMouseScroll scroll', (event) => {
// bla bla
this.onScroll$.next({тут нужные цифры скрола});
})
}
}
const oldData = [{id: 1, name: 'Vasya'}, {id: 'anyString', name: {}}];
const newData = oldData.map(function(item) {
const newItem = {};
newItem[item.id] = item.name;
return newItem;
});