Menu ▼



Posted By :
avatarmrkraju
Total Views : 353

AngularJS ng-include directory example

ng-copy
The ng-include directive is used to load other url (page) content in the current page.

Example

URL
http://dotnetlearners.com/



You can change the above text value to any of the following page to test the functionality.
activemembers.aspx
rss.xml

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <style type="text/css">
        .smplprv
        {
            padding: 10px;
            border: solid 1px #ccc;
        }
    </style>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular.min.js"></script>
</head>
<body>
    <div ng-app="myApp" ng-controller="myCntrl">
        URL<br />
        http://dotnetlearners.com/<input type="text" ng-model="sampleurl" />
        <br />
        <br />
        <div ng-include="includeurl()" ng-class="{smplprv:true}">
        </div>
    </div>
    <script language="javascript">
        var myapp = angular.module("myApp", []);
        myapp.controller("myCntrl", function ($scope) {
            $scope.sampleurl = "stats.aspx";
            $scope.includeurl= function(){
                return "/"+$scope.sampleurl;
            }
        });
    </script>
</body>
</html>






comments powered by Disqus


Search dotnetlearners.com