Skip to content

Instantly share code, notes, and snippets.

@adamweeks
Created May 28, 2015 16:34
Show Gist options
  • Save adamweeks/d5dd7647ecab677f3eb3 to your computer and use it in GitHub Desktop.
Save adamweeks/d5dd7647ecab677f3eb3 to your computer and use it in GitHub Desktop.
Angular Demo // source http://jsbin.com/jigiyozeya
<!DOCTYPE html>
<html ng-app="demo">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script>
<meta charset="utf-8">
<title>Angular Demo</title>
</head>
<body ng-controller="DemoController as demo">
<p>demo.welcome: {{demo.welcome}}</p>
<p>Name: <input ng-model="demo.inputValue"></p>
<p>demo.inputValue: {{demo.inputValue}}</p>
<p>Directive Below:</p>
<demo-directive
string-bind="{{demo.welcome}}"
object-bind="demo.inputValue"
function-bind="demo.myFunction()">
</demo-directive>
<script id="jsbin-javascript">
(function(){
angular.module("demo",[])
.controller('DemoController', DemoController)
.directive('demoDirective', DemoDirective)
;
function DemoController(){
var vm = this;
vm.hello = "Hi There!";
vm.welcome = vm.hello;
vm.myFunction = function(){
vm.welcome = vm.hello + ' ' + vm.inputValue;
};
}
function DemoDirectiveController(){
}
function DemoDirective(){
return {
restrict: 'E',
scope: {
stringBind: '@',
objectBind: '=',
functionBind: '&'
},
template: [
'<p>Demo Directive Here</p>',
'<p>String Bind: {{vm.stringBind}}</p>',
'<p>Function Bind: <button ng-click="vm.functionBind()">Perform</button>'
].join(''),
controllerAs: 'vm',
bindToController: true
};
}
})();
</script>
<script id="jsbin-source-javascript" type="text/javascript">(function(){
angular.module("demo",[])
.controller('DemoController', DemoController)
.directive('demoDirective', DemoDirective)
;
function DemoController(){
var vm = this;
vm.hello = "Hi There!";
vm.welcome = vm.hello;
vm.myFunction = function(){
vm.welcome = vm.hello + ' ' + vm.inputValue;
};
}
function DemoDirectiveController(){
}
function DemoDirective(){
return {
restrict: 'E',
scope: {
stringBind: '@',
objectBind: '=',
functionBind: '&'
},
template: [
'<p>Demo Directive Here</p>',
'<p>String Bind: {{vm.stringBind}}</p>',
'<p>Function Bind: <button ng-click="vm.functionBind()">Perform</button>'
].join(''),
controllerAs: 'vm',
bindToController: true
};
}
})();</script></body>
</html>
(function(){
angular.module("demo",[])
.controller('DemoController', DemoController)
.directive('demoDirective', DemoDirective)
;
function DemoController(){
var vm = this;
vm.hello = "Hi There!";
vm.welcome = vm.hello;
vm.myFunction = function(){
vm.welcome = vm.hello + ' ' + vm.inputValue;
};
}
function DemoDirectiveController(){
}
function DemoDirective(){
return {
restrict: 'E',
scope: {
stringBind: '@',
objectBind: '=',
functionBind: '&'
},
template: [
'<p>Demo Directive Here</p>',
'<p>String Bind: {{vm.stringBind}}</p>',
'<p>Function Bind: <button ng-click="vm.functionBind()">Perform</button>'
].join(''),
controllerAs: 'vm',
bindToController: true
};
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment