我正在開發演示應用程序來學習AngularJS。幾件讓我困擾的事情。很少有基本的問題困擾着我與AngularJS相關
1 -是什麼苦惱,因爲無論是工作的罰款
<div ng-controller="Page2Ctrl">
</div>
和
when('/page2', {templateUrl: 'views/flow1/page2.html', controller: 'Page2Ctrl'}).
之間的差異。即使在路由中定義了控制器,是否需要在Html中定義ng-controller
?
2 -是什麼第二
function Page4Ctrl($scope){
$scope.pageName = "Page 4 loaded."
}
而且
app.controller('Page4Ctrl', function ($scope) {
$scope.pageName = "Page 4 loaded."
});
之間的差別很冗長,需要額外的輸入。任何有關使用它們的建議?
3 -假設我正在爲客戶開發一個CRUD應用程序。我製作了一個CustomerController.js文件,我想把所有與客戶相關的方法(創建,讀取,更新,刪除,FindById,FindAll等)。如下所示。這是正確的方法還是控制器應該是一個包含所有CRUD方法的CustomerController?
app.controller('CustomerCreateController', function ($scope) {});
app.controller('CustomerEditController', function ($scope) {});
app.controller('CustomerDeleteController', function ($scope) {});
謝謝並理解每一個字。只要我進步,我會在上面提到的3個代碼中發佈更多的問題。 – Pirzada