angularjs Controller顯示物件屬性

  • 183
  • 0

<script src="~/Scripts/ngcontroller.js"></script>

 


<div ng-app="myModule">
    <div ng-controller="myController">
        FirstName:{{ employee.FirstName }}<br />
        LastName:{{ employee.LastName }}<br />
        Age:{{ employee.Age }}<br />
    </div>

</div>

 

ngcontroller.js

var myApp = angular.module("myModule", []);

myApp.controller("myController", function ($scope) {
    var employee = {
        FirstName: "Charles",
        LastName: "Chiang",
        Age: 30
    };


    $scope.employee = employee;
});