以下不加载是我的父/根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