以下不加載是我的父/根HTML和JS代碼:子視圖命名視圖
angular.module("myApp", ["ui.router"])
.config(function ($stateProvider) {
$stateProvider
.state("parent", {
templateUrl: 'Parent.html',
controller: 'ParentController'
})
.state('parent.child', {
views: {
'[email protected]': {
templateUrl: 'Child.html',
controller: 'ChildController'
}
}
})
})
.controller("ParentController", function ($scope, $state) {
$scope.currentTime = new Date();
$scope.count = 1;
$scope.LoadChildView = function() {
$state.go("parent.child");
}
$scope.Increment = function() {
$scope.count += 1;
}
})
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<title></title>
<meta charset="utf-8" />
<script src="../../../Scripts/angular.min.js"></script>
<script src="../../../Scripts/angular-ui-router.min.js"></script>
<script src="Parent.js"></script>
<script src="Child.js"></script>
</head>
<body ng-controller="ParentController">
Current time: {{currentTime}}
<input type="button" ng-click="Increment()" value="Increment" />
Count: {{count}}
<div>
<input type="button" ng-click="LoadChildView()" value="Load" />
</div>
<div ui-view="childView"></div>
</body>
</html>
當我點擊 「Load」 按鈕,內容/孩子的HTML。 html不會加載到父級的ui-view =「childView」中。
有什麼想法?
P.S .:這是一些額外的文本,因爲stackoverflow給我錯誤發佈這個問題,抱怨「帖子主要包含代碼,請添加一些更多的細節。」我不知道如何覆蓋這個。
您的孩子和家長視圖的網址是什麼? – Vivz