Skip to content

Instantly share code, notes, and snippets.

@allenyang79
Created August 29, 2013 10:41
Show Gist options
  • Save allenyang79/6376595 to your computer and use it in GitHub Desktop.
Save allenyang79/6376595 to your computer and use it in GitHub Desktop.
.error{
color:#f00;
}
.warning{
color:#0f0;
}
.highlight{
background:#efefef;
}
<html = ng-app="app">
<body ng-controller="MyCtrl">
<div>
x:<input type="text" ng-model="x"/><br/>
y:<input type="text" ng-model="y"/><br/>
ans:<input type="text" ng-attr-value="ans();" value="{{ans()|currency}}"/><br/>
{{x*y}}
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js"></script>
</body>
</html>
var app = angular.module('app',[]);
app.controller('MyCtrl', function($scope){
$scope.ans=function(){
return $scope.x*$scope.y;
};
$scope.$watch($scope.ans,function(newValue, oldValue, $scope){
//alert("X");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment