AngularJS-controller基本用法

Module:
HTML:
<html ng-app="模組名稱">

app=angular.module('模組名稱',[依賴的模組陣列])

angular.module('模組名稱',[依賴的模組陣列]) Controller: 執行或觸發UI導向工作的函式
Controller: 執行或觸發UI導向工作的函式
<body ng-controller="MyCtrl as ctrl">
{{ctrl.myTestMsg}}

app.controller('MyCtrl',[ function() {
    var self=this;
    self.myTestMsg='hello';
}]);

留言