Angular 2 code can be written in JavaScript, TypeScript, or Dart. In case you are writing Angular 2 code in TypeScript or Dart, you will need to transpile the code to JavaScript before serving to the client. We will use JavaScript to write Angular 2 code.
Create a directory named angular2-demo
. Then, inside the directory, create the app.js
and package.json
files. Then, create a directory named public
, and inside the directory, create four more directories named html
, js
, componentTemplates
, and componentStyles
. Now, create a file named index.html
and place it in the html
directory.
Then, download
angular2-polyfills.js
, Rx.umd.js
, and
angular2-all.umd.js
from https://cdnjs.com/libraries/angular.js/ and place them in the angular2-demo/js
directory. These files are what they sound like. You can also enqueue the CDN links directly if you want to.
Inside the index.html
file, place this starting code:
<!doctype html> <html> <head> <title...