Skip to content

Instantly share code, notes, and snippets.

@yngvebn
Last active September 21, 2015 09:49
Show Gist options
  • Save yngvebn/0278734dacdf356eceff to your computer and use it in GitHub Desktop.
Save yngvebn/0278734dacdf356eceff to your computer and use it in GitHub Desktop.
angular.module('app', []);
function MyComponent(TestService){
var vm = this;
this.greeting =TestService.greet();
console.log('We have a component');
}
MyComponent.templateUrl = 'test.tpl.html'
MyComponent.selector = 'my-new-component';
MyComponent.scope = {
value : '='
}
angular.module('app').component(MyComponent);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.js"></script>
<script src="app.js"></script>
</head>
<body ng-app="app">
<my-new-component value="'I was provided!'"></my-new-component>
</body>
</html>
angular.module('app').service('TestService', function(){
this.greet = function(){
return 'Hello from service';
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment