diff --git a/src/app/externs/angular-new-router.js b/src/app/externs/angular-new-router.js new file mode 100644 index 000000000000..5e6c397cb895 --- /dev/null +++ b/src/app/externs/angular-new-router.js @@ -0,0 +1,39 @@ +// Copyright 2015 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @fileoverview Externs for Angular router: https://github.com/angular/router + * + * TODO(bryk): Move the externs out of this project. + */ + + +/** @const */ +var ngNewRouter = {}; + + +/** + * @typedef {{ + * setTemplateMapping: function(function(string):string) + * }} + */ +ngNewRouter.$componentLoaderProvider = {}; + + +/** + * @typedef {{ + * config: function(!Array<{path: string, component: string}>) + * }} + */ +ngNewRouter.$router = {}; diff --git a/src/app/frontend/index.config.js b/src/app/frontend/index.config.js index d49152b4982d..351031e14210 100644 --- a/src/app/frontend/index.config.js +++ b/src/app/frontend/index.config.js @@ -13,8 +13,8 @@ // limitations under the License. -/** @ngInject */ -export function config($logProvider) { - $logProvider.debugEnabled(true); +/** + * @ngInject + */ +export function config() { } - diff --git a/src/app/frontend/index.html b/src/app/frontend/index.html index ec3d4630ec16..ed3d75dcf1e3 100644 --- a/src/app/frontend/index.html +++ b/src/app/frontend/index.html @@ -39,11 +39,6 @@ - - - - - diff --git a/src/app/frontend/index.module.js b/src/app/frontend/index.module.js index 7f08577d91d4..f179fa930090 100644 --- a/src/app/frontend/index.module.js +++ b/src/app/frontend/index.module.js @@ -14,10 +14,10 @@ /** * @fileoverview Entry point module to the application. Loads and configures other modules needed - * to bootstrap the application + * to bootstrap the application. */ import { config } from './index.config'; -import { routerConfig, RouterController } from './index.route'; +import { RouterController, routerConfig } from './index.route'; import { runBlock } from './index.run'; import { MainController } from './main/main.controller'; @@ -29,4 +29,3 @@ export default angular.module( .run(runBlock) .controller('RouterController', RouterController) .controller('MainController', MainController); - diff --git a/src/app/frontend/index.route.js b/src/app/frontend/index.route.js index 33923b301a78..50ff527eadad 100644 --- a/src/app/frontend/index.route.js +++ b/src/app/frontend/index.route.js @@ -13,20 +13,25 @@ // limitations under the License. -/** @ngInject */ +/** + * @param {!ngNewRouter.$componentLoaderProvider} $componentLoaderProvider + * @ngInject + */ export function routerConfig($componentLoaderProvider) { $componentLoaderProvider.setTemplateMapping(function(name) { - return `${ name }/${ name }.html`; + return `${name}/${name}.html`; }); } + export class RouterController { - /** @ngInject */ + /** + * @param {!ngNewRouter.$router} $router + * @ngInject + */ constructor($router) { - var router = $router; - router['config']([ + $router.config([ { path: '/', component: 'main' } ]); } } - diff --git a/src/app/frontend/index.run.js b/src/app/frontend/index.run.js index d339f1b940be..0f0b7f90f2a8 100644 --- a/src/app/frontend/index.run.js +++ b/src/app/frontend/index.run.js @@ -13,8 +13,10 @@ // limitations under the License. -/** @ngInject */ +/** + * @param {!angular.$log} $log + * @ngInject + */ export function runBlock ($log) { $log.debug('runBlock end'); } - diff --git a/src/app/frontend/main/main.controller.js b/src/app/frontend/main/main.controller.js index 588bd646bed3..dd949b6c8528 100644 --- a/src/app/frontend/main/main.controller.js +++ b/src/app/frontend/main/main.controller.js @@ -14,16 +14,19 @@ export class MainController { - /** @ngInject */ constructor() { + /** @export */ this.testValue = 7; } - /** @ngInject */ + /** + * @param {!angular.$timeout} $timeout + * @ngInject + * @export + */ activate($timeout) { $timeout(() => { - this.foo = 'bar'; + this.testValue = 8; }, 4000); } } - diff --git a/src/app/frontend/main/main.html b/src/app/frontend/main/main.html index 82e69ce4d089..a2712f0fdb6d 100644 --- a/src/app/frontend/main/main.html +++ b/src/app/frontend/main/main.html @@ -1,7 +1,7 @@
- Hello world! + Hello world! {{main.testValue}}
@@ -12,4 +12,3 @@

'Allo, 'Allo!

-