Thursday, March 2, 2017

Angularjs2 : Hello World Example


index.html

<!DOCTYPE html>
<html>
  <head>
    <title>Hello World</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/2.0.0-alpha.34/angular2.sfx.dev.js"></script>

  <script src="app.js"></script>
   </head>
<body>
   <my-app>Loading...</my-app>
</body>
</html>





app.js



function myApp() {
}
myApp.annotations = [
new ng.Component({
selector : "my-app"
}),
new ng.View({
template : "<div> <h1> Hello World </h1> </div>"
})
];
document.addEventListener("DOMContentLoaded", function(){
ng.bootstrap(myApp);
});


Output page






No comments:

Post a Comment