Skip to content

Instantly share code, notes, and snippets.

@nightbear1009
Created December 15, 2014 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nightbear1009/91988b926782f390c091 to your computer and use it in GitHub Desktop.
Save nightbear1009/91988b926782f390c091 to your computer and use it in GitHub Desktop.
angularJs - two way binding
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" ng-app>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>AngualrJs</title>
</head>
<body>
<input type="number" class="form-control" id="productPrice" placeholder="價格"
ng-model="newProduct.price">
</input>
<label > {{ newProduct.price}}</label>
<script src="../../node_modules/grunt-protractor-webdriver/bower_components/angular/angular.js"></script>
<script>
angular.module('app', []);
/*** 請移除scope,更換為controllerAs ***/
angular.module('app')
.controller('MainController', function ($scope) {
$scope.newProduct = {
name: '',
price: null
};
})
/*** end ***/
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment