Tagged: ng-include angular 4

ng Include – AngularJS ng-include Directive 0

ng Include - AngularJS ng-include Directive

ng Include – AngularJS ng-include Directive

In this Post We Will Explain About is ng Include – AngularJS ng-include Directive With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to AngularJS ng-include Directive Example

In this post we will show you Best way to implement AngularJS ng-include Directive with Example, hear for AngularJS switch HTML template with ng-include with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

AngularJS ng-include Directive

In this Example,First of all Add or Include External Libs Like as a(jQuery, css etc..), and then create a simple index.php or index.html page.After that crate a simple javascript file like as a index.js or main.js, It is also add your web-application First Header Part to some priority set.After that Include your relevant CSS Class.

External Include file

AngularJS is a simple JavaScript framework Include one type of the (library) based on a very user friedly popular software mvc based architecture menas called the MVC.

   <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js"></script>

index.html

The Angular simple directives and the User’s view HTML DOM in a web-application page form the HTML view. In our example(Pakainfo.com), the simple HTML view comprises the HTML All the element, and then simple two angular directives Like as a namely angular ng-app as well as agular ng-controller

<div ng-controller="liveCtrl">
    <select ng-model="pageName" ng-options="t.name for t in alltemplates">
     <option value="">(blank)</option>
    </select>
    url of the pageName: <tt>{{pageName.url}}</tt>
    <hr/>
    <div ng-include src="pageName.url" onload='myFunction()'></div>
  </div>
  
<!-- home.html -->
<script type="text/ng-pageName" id="home.html">
  Content of home.html
</script>
 
<!-- about.html -->
<script type="text/ng-pageName" id="about.html">
    <p ng-class="color">Content of about.html</p>
</script>


index.js

The simple angular controller works as a all the data of the mediator between HTML views and models.

function liveCtrl($scope) {
    $scope.alltemplates = [{
        name: 'home.html',
        url: 'home.html'},
    {
        name: 'about.html',
        url: 'about.html'}];
    $scope.pageName = $scope.alltemplates[0];

    $scope.myFunction = function() {
        $scope.color = 'red';
    }
}

style.css

.red { color:green; }

AngularJS ng-include Directive

You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example

Example

I hope you have Got What is Custom directives over ng-include directive And how it works.I would Like to have FeedBack From My Blog(Pakainfo.com) readers.Your Valuable FeedBack,Any Question,or any Comments about This Article(Pakainfo.com) Are Most Always Welcome.