Skip to main content

ng-include in angularjs

Ng-include Directive :

        An ng-include is use to inject a DOM in any html pages. This inject DOM component is active scope in mention or declared controllers.

       A purpose of ng-include is reuse the DOM component in more than pages. Say for example header page section is common to the all pages means, This DOM element move to one file and than this file include all the pages.

<ng-include src="" onload="" autoscroll="">
 
or

<div ng-include="" onload="" autoscroll="">


src  - give your dom component file path.
onload - any action you will make on load the dom
autoscroll - if need scroll you can apply here

Sample:

<div ng-include="'templates/include/header_tpl.html'"></div>
 or
<div ng-include="'templates/include/header.tpl'"></div>

.tpl or .html you save the template file format. These format is supported ng-include.

<ion-view>
<div ng-include="'templates/include/header.tpl'"></div>
  <ion-content >  
       <div >EVENTS</div>
          .................
        </div>
</ion-content>
</ion-view>
       

Comments

Popular posts from this blog

How has lockdown impacted Indian farmers?

How has lockdown impacted Indian farmers?             Generally compare to other sectors it's not major impacted by our Indian farmers but we acceptable minor impacts. Here we separate major two farming cultures one is mono farming culture another one poly farming culture. Mono farming :             The major impacts from our Indian farmer for monoculture. Here I have briefly explained what are the things we had faced our local farmers. Here I explain two different crops type: Daily crops : * We harvest more than 100-kilo grams daily crops like brinjal but we unable to sell those in local markets. * We are unable to reach urban markets. * We don't have enough transport facilities. * We unable buy require fertilizer and other complements * In the early stage we are facing manpower shortage but later it's not an issue. * We unable to do value-added products. * Waste is very high for somedays Se...

Timer Display using AngularJS

Timer Display To display timer in a page means, we need to aware of angular directive as following $interval and $filter . Current time get from new Date() object from native java script.   $interval Directive:  A interval is wait into a millisecond or trigger to a function, This function many many time to repeatedly calling process is control to us.   Syntax:  $interval(fn, delay, [count], [invokeApply]); fn - a function to call repeatedly. Delay – number of millisecond to call a function. Count – Number of time to repeat.(0 value means no-repeat) invoteApply – set to false means it will skip. Example:  HTML: <div ng-app="timerApp">     <div ng-controller="timerController">         {{time}}     </div> </div> JAVAScript: var app = angular.module("timerApp", []); app.controller("timerController",['$scope','$interval...

ng-Class using angularjs Example

ng-Class in angularJS         ng-Class directive to manage a css properties from the DOM Objects. This directive very support to user presentation css apply dynamically and more response, angularjs used for bootstrap css only. Write different properties from the css file and enable from the controller scope object values. HTML:    <div ng-app="classApp">     <div ng-controller="ClassCtrl">        <span ng-if="showValue">         <p ng-class ="{'red': show, 'green': show1}">{{name}}         </p>         </span>          <span ng-if="!showValue">         <p ng-class ="{'red': show, 'green': show1}">{{name}}         </p>         </span>     </div> </div> Angular Script: ...