Created
February 8, 2019 18:22
-
-
Save anurag-majumdar/642d58b7fbf0794100a65e4b3fc2abbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { appTemplate } from './app.template'; | |
import { AppModel } from './app.model'; | |
export const AppComponent = { | |
init() { | |
this.appElement = document.querySelector('#app'); | |
this.initEvents(); | |
this.render(); | |
}, | |
initEvents() { | |
this.appElement.addEventListener('click', event => { | |
if (event.target.className === 'btn-todo') { | |
import( /* webpackChunkName: "todo" */ './todo/todo.module') | |
.then(lazyModule => { | |
lazyModule.TodoModule.init(); | |
}) | |
.catch(error => 'An error occurred while loading Module'); | |
} | |
}); | |
document.querySelector('.banner').addEventListener('click', event => { | |
event.preventDefault(); | |
this.render(); | |
}); | |
}, | |
render() { | |
this.appElement.innerHTML = appTemplate(AppModel); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment