Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html ng-app="sampleApp">
<head>
  <meta charset="utf-8">
  <title>Lab 10 - 計算型屬性執行次數</title>
</head>
<body>
  <div ng-controller="mainCtrl">
    <input type="text" ng-model="model.firstName" />
    <input type="text" ng-model="model.lastName" />
    <br />
    <span ng-bind="model.fullName()"></span>
  </div>
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.js"></script>
  <script>
    angular.module("sampleApp", [])
    .controller("mainCtrl", function($scope) {
      function myViewModel() {
        var self = this;
        self.firstName="Jeffrey";
        self.lastName="Lee";
        var c = 0;
        self.fullName = function() {
          window.console && console.log(
            "fullName() calculated(" + (c++) + "): " + 
            self.firstName + " " + self.lastName);
          return self.firstName + " " + self.lastName + " " +
            Math.random();
        };
      }
      $scope.model = new myViewModel();
    });
  </script>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
darkthreadpro
0viewers