We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Load partial view using treeview

I have to to following functionality using angularjs

controller code...

<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"/>

</div>



i want t oload partial view at ng-include


view code....


var UrlData = [{ id: 2, pid: 1, url: '../view/fictionbooks/FictionBook1.html' },
               { id: 3, pid: 1, url: "../view/fictionbooks/FictionBook2.html" },
.................
...............
...];


    $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;
            }
        }

    }






1 Reply

SN Sasikala Nagarajan Syncfusion Team June 3, 2015 03:40 AM UTC

Hi Gomtesh,

Thanks for using Sycnfusion products,

We have analyzed your requirement and prepared the sample based on your requirement. Please get the sample from below location

Sample

To set the scope variable as src to ng-inlcude, please refer the below code snippet

[html]

<ng-include src="viewPage"></ng-include>



To bind the updated scope variable value, we have to call $scope.$apply() method for binding. Please refer the below code snippet

Angular controller:


$scope.loadpage = function (args) {

for (var i = 0; i < UrlData.length; i += 1) {


var jsonobject = UrlData[i];


if (jsonobject.id == args.id) {


$scope.viewPage = jsonobject.url;


}

$scope.$apply();

}

};


Please check with the given sample and let us know if you have further queries,

Regards,

Sasikala Nagarajan


Loader.
Live Chat Icon For mobile
Up arrow icon