Skip to content

Commit

Permalink
attempt to bootstrap AngularJS app (1.4) - not successful
Browse files Browse the repository at this point in the history
  • Loading branch information
scottschafer committed Mar 31, 2017
1 parent 89610d2 commit 4b2c7c5
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .angular-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
"favicon.ico",
"ng1app"
],
"index": "index.html",
"main": "main.ts",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"@angular/upgrade": "^4.0.0",
"core-js": "^2.4.1",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"
Expand Down
13 changes: 9 additions & 4 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { AppComponent } from './app.component';
import { UpgradeModule } from '@angular/upgrade/static';

@NgModule({
declarations: [
Expand All @@ -12,9 +13,13 @@ import { AppComponent } from './app.component';
imports: [
BrowserModule,
FormsModule,
HttpModule
HttpModule,
UpgradeModule
],
providers: [],
bootstrap: [AppComponent]
providers: [] /*,
bootstrap: [AppComponent] */
})
export class AppModule { }
export class AppModule {
ngDoBootstrap() {}

}
17 changes: 17 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,25 @@

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">

<!-- IMPORTED FROM NG1-INDEX.HTML -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.7/angular.min.js"></script>
<script src="./ng1app/ng1-script.js"></script>

</head>

<!-- ANGULAR2-CLI GENERATED:
<body>
<app-root>Loading...</app-root>
</body>
-->

<!-- IMPORTED FROM NG1-INDEX.HTML -->
<body>
<div ng-controller="Ng1Ctrl">
{{angular1Msg}}
</div>
</body>

</html>
8 changes: 7 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
import { UpgradeModule } from '@angular/upgrade/static';

if (environment.production) {
enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule);
//platformBrowserDynamic().bootstrapModule(AppModule);

platformBrowserDynamic().bootstrapModule(AppModule).then(platformRef => {
const upgrade = platformRef.injector.get(UpgradeModule) as UpgradeModule;
upgrade.bootstrap(document.body, ['ng1app'], {strictDi: true});
});
19 changes: 19 additions & 0 deletions src/ng1app/ng1-index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html ng-app="ng1app">
<head>
<meta charset="utf-8">
<title>Test NG1 app </title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.7/angular.min.js"></script>
<script src="ng1-script.js"></script>
</head>

<body>
<div ng-controller="Ng1Ctrl">
{{angular1Msg}}
</div>
</body>

</html>
10 changes: 10 additions & 0 deletions src/ng1app/ng1-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(function () {
'use strict';

angular.module('ng1app', [])
.controller('Ng1Ctrl', ['$scope',
function ($scope) {
$scope.angular1Msg = 'Greetings from Angular 1';
}]);

})();

0 comments on commit 4b2c7c5

Please sign in to comment.