我對AngularJS非常陌生。這是我的第一個項目,所以請原諒我,如果我的問題是非常基本的。在單頁應用程序中使用Angularjs點擊按鈕時加載視圖
我使用簡單的HTML創建了一個頁面,並在其上放置了三個按鈕。 在這些按鈕上單擊我想要在屏幕低部分加載視圖。
的Index.html
<body ng-app="MyApp">
<div class="tab" ng-controller="TabControlController">
<button class="tablinks" onclick="openTab(event, 'Environments')" ng-click="Views/EnvironmentsView.html">Environments</button>
<button class="tablinks" onclick="openTab(event, 'SIT_Downloader')" ng-click="Views/SITDownloaderView.html">Download PCP Client</button>
<button class="tablinks" onclick="openTab(event, 'Users')">PCP Users</button>
</div>
<div id="Environments" class="tabcontent" ng-controller="environmentController">
<div>
<div ng-view></div>
</div>
</div>
<div id="SIT_Downloader" class="tabcontent" ng-controller="SITDownloaderController">
<div>
<div ng-view></div>
</div>
</div>
<div id="Users" class="tabcontent">
<div>
<div ng-view></div>
</div>
</div>
</body>
Bootstrap.js
var MyApp= angular.module('MyApp', ['ngRoute'])
.config(function($routeProvider) {
$routeProvider
.when('/',
{
templateUrl: 'Views/EnvironmentsView.html',
controller: window.environmentController
})
.otherwise({ redirectTo: '/' });
});
觀點截至目前很簡單...
<h3>PCP Users</h3>
<p>This screen will be used to add/remove users</p>
誰能幫我瞭解我是什麼在這裏丟失或重定向我的一些頁面,完整的例子。
這是單頁面應用程序。
你可以創建小提琴嗎?在控制器中它應該是environmentController而不是window.controller – MehulJoshi