我必须根据列表视图选项加载部分视图 我使用了syncfusion listview控件 我也不必在地址栏中更改网址...........
<div ng-controller="SidebarController">
<a id="treeView" ej-treeview e-fields-datasource="dataList" e-fields-id="id" e-fields-parentid="pid" e-fields-text="name" e-datasource="localdata" e-fields-haschild="hasChild" e-fields-expanded="expanded" e-fields-imageurl="imageUrl" e-nodeselect="selected" />
<div ng-include="viewurl"/>
这是控制器代码
SyncfusionDemoApp.controller('SidebarController', function ($scope, $location, $filter, CommonService) {
// alert("Sidebarcontroller");
$scope.dataList = ListViewData;
$scope.selected = function (args) {
for (var i = 0; i < UrlData.length; i += 1) {
var jsonobject = UrlData[i];
if (jsonobject.id == args.id) {
$scope.viewurl = jsonobject.url;
//$scope.show = true;
CommonService.Url = UrlData.url;
}
}
alert($scope.viewurl);
console.log($scope.viewurl);
}
});
这里是JSON :::
var ListViewData = [
{ id: 1, name: "Fiction Book Lists", hasChild: true, expanded: true },
{ id: 2, pid: 1, name: "Fiction Book1", },
{ id: 3, pid: 1, name: "Fiction Book2" },
{ id: 4, name: "Mystery Book Lists", hasChild: true, expanded: true },
{ id: 5, pid: 4, name: "Mystery Book1" },
{ id: 6, pid: 4, name: "Mystery Book2" },
{ id: 7, name: "Horror Novels", hasChild: true },
{ id: 8, pid: 7, name: "Horror Book1" },
{ id: 9, name: "Novel Lists", hasChild: true },
{ id: 10, pid: 9, name: "Novel Book1" }];
var UrlData = [{ id: 2, pid: 1, url: '../view/fictionbooks/FictionBook1.html' },
{ id: 3, pid: 1, url: '../view/fictionbooks/FictionBook2.html' },
{ id: 5, pid: 4, url: '../view/mysterybooks/MysteryBook1.html' },
{ id: 6, pid: 4, url: "../view/mysterybooks/MysteryBook2.html" },
{ id: 8, pid: 7, url: "../view/horrorbooks/HorrorBook1.html" },
{ id: 10, pid: 9, url: "../view/novelbooks/NovelBook1.html" }];