Reputation: 1438
Here is the situation: I'm using async. script loading with systemJS (by scripts, I mean jQuery, Angular2, ...). Now I would like to implement Turbolinks into this. Everything works just fine, but my angular component is rendered only the first time. If I use Turbolinks to see next page, my component is not rendering. No errors in object inspector and in source code is only this:
<search-app></search-app>
I've tired test in object inspector but after second page lead this is only HTML tag.
Here are my loading scripts in SystemJS in Head tag on my page:
System.config({
meta: {
'/bundles/frontall': { format: 'global' },
'/bundles/raphael': { format: 'global' },
'/bundles/zopim': { format: 'global' },
'/bundles/angular2': { format: 'global' }
},
packages: {
'angular': {
format: 'register',
defaultExtension: 'js'
},
'angular2': {
format: 'global',
defaultExtension: 'js'
},
'rxjs': {
format: 'global',
defaultExtension: 'js'
}
},
paths: {
'angular2/*': 'scripts/angular2/*',
'rxjs/*': 'scripts/rxjs/*'
}
});
System.import('/bundles/frontall').then(function () {
Promise.all([
System.import('/bundles/zopim'),
System.import('/bundles/raphael'),
System.import('bundles/angular2'),
@RenderSection("asyncScripts", required: false)
]).then(function () {
System.import('angular/searchApp');
});
In the frontAll bundle is file site.js, where I re-initing all components:
function componentInit() {
//init material design
$.material.init();
//init texarea autosize
autosize($('textarea'));
//init parallax
$('.parallax-window').parallax();
//init smooth scroll
//SmoothScroll();
//init css3 animate it
$.animateIt();
$.doTimeout();
$.animateItInit();
$.srSmoothscroll({
step: 80,
speed: 90,
ease: 'linear',
target: $('body'),
container: $(window)
});
}
$(function () {
componentInit();
});
$(document).on('page:load', function () {
componentInit();
});
Angular 2 version is beta 7. Does anybody know where is the problem? Thanks a lot!
Upvotes: 2
Views: 382
Reputation: 1438
I need to add this to my angular2 app and it works:
jQuery(function () {
bootstrap(searchApp, [ElementRef, TournamentSearchService]);
});
jQuery(document).on('page:load', function () {
bootstrap(searchApp, [ElementRef, TournamentSearchService]);
});
Upvotes: 0