Created
May 28, 2015 16:34
-
-
Save adamweeks/d5dd7647ecab677f3eb3 to your computer and use it in GitHub Desktop.
Angular Demo // source http://jsbin.com/jigiyozeya
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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