Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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