import {CookieModule} from 'ngx-cookie'; // import CookieMonster
// XXX required for multi-mode
-import {UpgradeModule} from '@angular/upgrade/static';
+import {UpgradeModule, downgradeInjectable} from '@angular/upgrade/static';
+
import {Router} from '@angular/router';
import {EgBaseComponent} from './app.component';
) {}
ngDoBootstrap() {
- console.log('ngDoBootstrap()');
+ let myWin: any = window; // make TS happy
- let myWin: any = window;
+ console.log(`Ang2 loading Ang1 app ${myWin.ang1PageApp}`);
if (!myWin.ang1PageApp) {
console.error('NO PAGE APP DEFINED');
return;
}
- /*
- angular.module(myWin.ang1PageApp).directive('heroDetail',
- downgradeComponent({ component: HeroDetailComponent })
- );
- */
+ angular.module(myWin.ang1PageApp)
+ /*
+ .directive('heroDetail',
+ downgradeComponent({ component: HeroDetailComponent })
+ */
+ .factory('eg2Net', downgradeInjectable(EgNetService))
+ ;
// some of our ang1 apps are not strict-di compliant :(
this.upgrade.bootstrap(document.body, [myWin.ang1PageApp]);
- //this.upgrade.bootstrap(document.body, [myWin.ang1PageApp], { strictDi: true });
}
}
<!doctype html>
[%- PROCESS 'staff/config.tt2' %]
<html lang="[% ctx.locale %]"
- [%- IF ctx.page_app %] xng-app="[% ctx.page_app %]"[% END -%]
- [%- IF ctx.page_ctrl %] ng-controller="[% ctx.page_ctrl %]"[% END %]>
+ [%- IF NOT ctx.is_ang2_app %]
+ [%- IF ctx.page_app %] ng-app="[% ctx.page_app %]"[% END -%]
+ [%- IF ctx.page_ctrl %] ng-controller="[% ctx.page_ctrl %]"[% END %]
+ [% END %]>
<head>
- <script>
- [%- IF ctx.page_app %]
- // tell ang2 what ang1 wants to load.
- window.ang1PageApp = "[% ctx.page_app %]";
- [% END -%]
- </script>
+ [% IF ctx.is_ang2_app AND ctx.page_app %]
+ <script>
+ // tell ang2 what ang1 app to load
+ window.ang1PageApp = "[% ctx.page_app %]";
+ </script>
+ [% END %]
<!-- enables ng-cloak to be usable before angular has been able to fully load -->
<style type="text/css">
[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
PROCESS APP_JS;
# Angular2 scripts must be imported after app-specific ang1 imports
- INCLUDE "staff/ang2_js.tt2";
+ IF ctx.is_ang2_app;
+ INCLUDE "staff/ang2_js.tt2";
+ END;
%]
<!-- content printed via the browser is inserted here for
WRAPPER "staff/base.tt2";
ctx.page_title = l("Check In");
ctx.page_app = "egCheckinApp";
+ ctx.is_ang2_app = 1;
%]
[% BLOCK APP_JS %]
* Manages checkin
*/
.controller('CheckinCtrl',
- ['$scope','$q','$window','$location', '$timeout','egCore','checkinSvc','egGridDataProvider','egCirc', 'egItem',
-function($scope , $q , $window , $location , $timeout , egCore , checkinSvc , egGridDataProvider , egCirc, itemSvc) {
+ ['$scope','$q','$window','$location', '$timeout','egCore',
+ 'checkinSvc','egGridDataProvider','egCirc','egItem','eg2Net',
+function($scope , $q , $window , $location , $timeout , egCore ,
+ checkinSvc , egGridDataProvider , egCirc, itemSvc , eg2Net) {
+
+ eg2Net.request('open-ils.actor', 'opensrf.system.echo', 'Hello, Ang2')
+ .subscribe(function(res) {console.log('eg2Net returned ' + res)});
$scope.focusMe = true;
$scope.checkins = checkinSvc.checkins;