服务
public getSocialMedia() {
this._http.get(this.apiUrl).map(response => response.json()).subscribe(data => {
// console.log( data.socialwall );
this._dataStore.socialwall = data.socialwall;
//console.log(this._SocialObserver);
this._SocialObserver.next(this._dataStore.socialwall);
}, error => console.log('Could not load socialwall.'));
}
组件
ngOnInit() {
var container = jQuery('#masonry');
setTimeout(function() {
container.masonry({
columnWidth: 5,
itemSelector: '.grid-item',
isFitWidth: true,
isAnimated: true,
gutter: 15,
animationOptions: {
duration: 300,
queue: false
}
})
console.log('sdf');
}, 5000);
模板
<ul class="list-reset social-wall-container" id="masonry">
<li *ngFor="#social of socialwall | async" [outerHTML]="social.tile_content" (complete)="onCompletingTodo()"></li>
</ul>
答案 0 :(得分:1)
您可以在针对SocialObservable
的订阅回调中初始化容器:
ngOnInit() {
this.this._SocialObservable.subscribe(() => {
container.masonry({
columnWidth: 5,
itemSelector: '.grid-item',
isFitWidth: true,
isAnimated: true,
gutter: 15,
animationOptions: {
duration: 300,
queue: false
}
})
});
}
我认为SocialObservable
是SocialObserver
来自this._SocialObserver.next(this._dataStore.socialwall);
的观察点。
这样,执行container.masonry(...)
时,将调用if(classe != null && classe.contains(“idiom”))
{
Spannable spannable = new SpannableString(classe);
spannable.setSpan(new ForegroundColorSpan(Color.BLUE), classe.indexOf(“idiom”), classe.indexOf(“idiom”) + “idiom”.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
txtclasse.setText(spannable);
}
。