mirror of
https://github.com/nasa/openmct.git
synced 2025-05-11 13:03:03 +00:00
[Example] Add example of service registration
Add an example of registering a plain service with Angular. WTD-518.
This commit is contained in:
parent
ed4c178a76
commit
3ed3ee19d7
@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "Angular Built-ins Example",
|
"name": "Angular Built-ins Example",
|
||||||
"description": "Example showing how to declare extensions with built-in support from Angular.",
|
"description": "Example showing how to declare extensions with built-in support from Angular.",
|
||||||
|
"sources": "src",
|
||||||
"extensions": {
|
"extensions": {
|
||||||
"controllers": [
|
"controllers": [
|
||||||
{
|
{
|
||||||
"key": "ExampleController",
|
"key": "ExampleController",
|
||||||
"implementation": "ExampleController.js",
|
"implementation": "ExampleController.js",
|
||||||
"depends": [ "$scope" ]
|
"depends": [ "$scope", "exampleService" ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"directives": [
|
"directives": [
|
||||||
@ -21,7 +22,10 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"services": [
|
"services": [
|
||||||
|
{
|
||||||
|
"key": "exampleService",
|
||||||
|
"implementation": "ExampleService.js"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,8 +12,8 @@ define(
|
|||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function ExampleController($scope) {
|
function ExampleController($scope, exampleService) {
|
||||||
$scope.phrase = "I am a controller.";
|
$scope.phrase = exampleService.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ExampleController;
|
return ExampleController;
|
||||||
|
25
example/builtins/src/ExampleService.js
Normal file
25
example/builtins/src/ExampleService.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*global define,Promise*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module defining ExampleService. Created by vwoeltje on 11/4/14.
|
||||||
|
*/
|
||||||
|
define(
|
||||||
|
[],
|
||||||
|
function () {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function ExampleService() {
|
||||||
|
return {
|
||||||
|
getMessage: function () {
|
||||||
|
return "I heard this from a service";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return ExampleService;
|
||||||
|
}
|
||||||
|
);
|
Loading…
x
Reference in New Issue
Block a user