Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,12 @@ The application is a simple contacts application where you can search, create or
- Use `for..of` instead of `angular.forEach`
- Use `Promise` instead of `$q`
- Use `service` instead of `factory`



### Step 6 - Dual Boot

- Add Angular dependencies to `package.json`
- Add `polyfills.ts` file
- Remove `ng-app` from `index.html` file
- Add polyfills, `NgModule` and hybrid bootstrap code to `app.main.ts`

13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@
"author": "",
"license": "ISC",
"dependencies": {
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/upgrade": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"core-js": "^2.4.1",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4",

"angular": "^1.6.2",
"angular-animate": "^1.6.2",
"angular-auto-validate": "^1.19.0",
Expand Down
25 changes: 24 additions & 1 deletion src/app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,31 @@ import 'angular-ui-router';

import './app.main';
import './services';
import './directives';
import './filters';
import './components';
import './app.routes';
import './polyfills.ts';

import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {UpgradeModule} from '@angular/upgrade/static';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';

@NgModule({
imports: [
BrowserModule,
UpgradeModule
]
})
export class AppModule {
// Override Angular bootstrap so it doesn't do anything
ngDoBootstrap() {
}
}

// Bootstrap using the UpgradeModule
platformBrowserDynamic().bootstrapModule(AppModule).then(platformRef => {
console.log("Bootstrapping in Hybrid mode with Angular & AngularJS");
const upgrade = platformRef.injector.get(UpgradeModule) as UpgradeModule;
upgrade.bootstrap(document.body, ['codecraft']);
});
19 changes: 19 additions & 0 deletions src/app/polyfills.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// This file includes polyfills needed by Angular and is loaded before
// the app. You can add your own extra polyfills to this file.
import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/set';
import 'core-js/es6/reflect';

import 'core-js/es7/reflect';
import 'zone.js/dist/zone';
3 changes: 1 addition & 2 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<!DOCTYPE html >
<html lang="en"
ng-app="codecraft">
<html lang="en">
<head>
<title>Contacts</title>
<link href="libs/bootstrap/dist/css/bootstrap.min.css"
Expand Down