Skip to content

Commit

Permalink
Merge pull request #8 from kubernetes/compiled-code
Browse files Browse the repository at this point in the history
Annotate JS source to make Closure Compiler work
  • Loading branch information
PeWu committed Oct 23, 2015
2 parents 7667225 + ad15e58 commit d80fe3b
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 26 deletions.
39 changes: 39 additions & 0 deletions src/app/externs/angular-new-router.js
Original file line number Diff line number Diff line change
@@ -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 = {};
8 changes: 4 additions & 4 deletions src/app/frontend/index.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.


/** @ngInject */
export function config($logProvider) {
$logProvider.debugEnabled(true);
/**
* @ngInject
*/
export function config() {
}

5 changes: 0 additions & 5 deletions src/app/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@
<!-- inject:js -->
<!-- Application JS files are populated here. -->
<!-- endinject -->

<!-- inject:partials -->
<!-- Angular templates are automatically converted to JS and inserted here (prod build). -->
<!-- endinject -->
<!-- endbuild -->
</body>
</html>

5 changes: 2 additions & 3 deletions src/app/frontend/index.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -29,4 +29,3 @@ export default angular.module(
.run(runBlock)
.controller('RouterController', RouterController)
.controller('MainController', MainController);

17 changes: 11 additions & 6 deletions src/app/frontend/index.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
]);
}
}

6 changes: 4 additions & 2 deletions src/app/frontend/index.run.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
// limitations under the License.


/** @ngInject */
/**
* @param {!angular.$log} $log
* @ngInject
*/
export function runBlock ($log) {
$log.debug('runBlock end');
}

11 changes: 7 additions & 4 deletions src/app/frontend/main/main.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

3 changes: 1 addition & 2 deletions src/app/frontend/main/main.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div layout="vertical" layout-fill>
<md-content>
<header>
Hello world!
Hello world! {{main.testValue}}
</header>

<section class="jumbotron">
Expand All @@ -12,4 +12,3 @@ <h1>'Allo, 'Allo!</h1>
</section>
</md-content>
</div>

0 comments on commit d80fe3b

Please sign in to comment.