Here is Kyle's sample which I partially modified:
Sample html:
<div id="tab1EnhancedAddCmts" ng-app="NowPlaying">
<div ng-controller="MyCtrl">
<input
type="text" ng-model="username">
<h1>Hello {{username}}</h1>
<h2>My Favorite
Libraries</h2>
<ul><li ng-repeat="library in libraries">{{library}}</li></ul>
<button ng-click="doSomething()">Click
Me!</button>
</div>
</div>
Sample javascript:
<script language="javascript"
src="appcontent/js/libs/angular/1.2.16/angular.min.js"></script>
<script type="text/javascript"
language="javascript">
var app =
angular.module('NowPlaying', []);
app.controller(‘MyCtrl’, ['$scope', ' NowPlayingSvc',
function($scope, NowPlayingSvc) {
$scope.doSomething
= function() {
alert('doSomething');
NowPlayingSvc.libraries.push($scope.username);
};
$scope.username = 'Kyle
Buchanan';
$scope.libraries = NowPlayingSvc.libraries;
}]);
app.factory('NowPlayingSvc', [
function() {
return {
libraries: [
'MooTools',
'Scriptaculous',
'Ember'
]
};
}]);
</script>
More info:
No comments:
Post a Comment