From b712c9a4019fb876dca9b7406b61904c299880b5 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 4 Nov 2014 15:28:53 -0800 Subject: [PATCH] [Example] Add controller example Add example showing declarative registration of controllers with Angular. WTD-518. --- example/builtins/bundle.json | 6 +++++- example/builtins/res/templates/example.html | 3 ++- example/builtins/src/ExampleController.js | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 example/builtins/src/ExampleController.js diff --git a/example/builtins/bundle.json b/example/builtins/bundle.json index 5aa0f821a0..d43a659de8 100644 --- a/example/builtins/bundle.json +++ b/example/builtins/bundle.json @@ -3,7 +3,11 @@ "description": "Example showing how to declare extensions with built-in support from Angular.", "extensions": { "controllers": [ - + { + "key": "ExampleController", + "implementation": "ExampleController.js", + "depends": [ "$scope" ] + } ], "directives": [ diff --git a/example/builtins/res/templates/example.html b/example/builtins/res/templates/example.html index 2aceaa7d30..8323a4f7c9 100644 --- a/example/builtins/res/templates/example.html +++ b/example/builtins/res/templates/example.html @@ -1 +1,2 @@ -

Hello, world! I am the default route.

\ No newline at end of file +

Hello, world! I am the default route.

+

My controller has told me: "{{phrase}}"

\ No newline at end of file diff --git a/example/builtins/src/ExampleController.js b/example/builtins/src/ExampleController.js new file mode 100644 index 0000000000..57defc0eaf --- /dev/null +++ b/example/builtins/src/ExampleController.js @@ -0,0 +1,21 @@ +/*global define,Promise*/ + +/** + * Module defining ExampleController. Created by vwoeltje on 11/4/14. + */ +define( + [], + function () { + "use strict"; + + /** + * + * @constructor + */ + function ExampleController($scope) { + $scope.phrase = "I am a controller."; + } + + return ExampleController; + } +); \ No newline at end of file