AngularJS Controllers Inheritance – angular inherits Example

AngularJS Controllers Inheritance – angular inherits Example

First include the AngularJS simple library or angular.min.js in the web-application. The ng-app simple directive (init module)initializes the application. The events of ng-controller directive simple data defines the ng-controller.
We defined simple two ng-controllers here define and set their html simple properties using here $scope object or json object. The second controller inherit all the parent and chield the message data property and overrides all the content the color side effect property from first controller. It also add all the data “type” property which simple not be available for first controller.

AngularJS Multiple and Scope Controllers Example

Include libs

angular.js
index.js

index.html

  
 <h1>AngularJS Controllers Inheritance</h1>
<div>  
    <div>  
      <a href="#">ResultQuiz</a>  
    </div>  
	<pre>
    {{ "EmpName Name : " + EmpName.name }} </br>  
    {{ 'Total Marks: ' + EmpName.scoarTotal }}   
	</pre>
 </div>
<a href="https://infinityknow.com" target="_blank" title="Download,free download,steps download,download quickly,easy download,steps download,all download" class="download">Example</a> 
 

index.js

var infinityApp = angular.module('infinityApp', []);  
    infinityApp.controller('FirstCtrl', function($scope) {    
      $scope.EmpName = {scoarTotal: false } ;  
    });   
    infinityApp.controller('secondCtrl', function($scope) {  
      $scope.ResultQuiz = function() {  
        $scope.EmpName.name = "infinityknow";  
        $scope.EmpName.scoarTotal = true;  
      }  
    });  

AngularJS Controllers : Multiple Controllers Example

  

  <!-- www.infinityknow.com -->
<title>AngularJS Controllers Inheritance code Example</title>  
<a href="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js">https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js</a>  
  
var infinityApp = angular.module('infinityApp', []);  
    infinityApp.controller('FirstCtrl', function($scope) {    
      $scope.EmpName = {scoarTotal: false } ;  
    });   
    infinityApp.controller('secondCtrl', function($scope) {  
      $scope.ResultQuiz = function() {  
        $scope.EmpName.name = "infinityknow";  
        $scope.EmpName.scoarTotal = true;  
      }  
    });  
  
  
  
 <h1>AngularJS Controllers Inheritance</h1>
<div>  
    <div>  
      <a href="#">ResultQuiz</a>  
    </div>  
	<pre>
    {{ "EmpName Name : " + EmpName.name }} </br>  
    {{ 'Total Marks: ' + EmpName.scoarTotal }}   
	</pre>
 </div>
<a href="https://infinityknow.com" target="_blank" title="Download,free download,steps download,download quickly,easy download,steps download,all download" class="download">Example</a> 
  
 

Example

READ :  VueJs Data Binding - Vuejs Two Way Data Binding Example

Add a Comment

Your email address will not be published. Required fields are marked *