Skip to content

adityajadhav/angular-dynamic-controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Angular Dynamic Controller

This directive allows you to dynamically specify a controller name to inject into html template

Installation

Install using bower

bower install --save angular-dynamic-controller

Load the script files into your application.

<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-dynamic-controller/lib/angular-dynamic-controller.js"></script>

Add this module as a dependency in your AngularJS app.

angular.module('myApp', [ 'aj.angular-dynamic-controller' ]);

Usage

The dynamicController directive which include the controller name dynamically.

To use this directive use attribute 'dynamic-controller' in the following way.

<tabset> 
	<tab ng-repeat="tab in tabs" active=tab.active> 
		<tab-heading>{{tab.title}} </tab-heading>
			<div ng-include="tab.template" dynamic-controller="tab.controller"></div>
	</tab> 
</tabset>
var myApp = angular.module('myApp',[]);

myApp.controller('TabCtrl', ['$scope', function($scope) {
  
  $scope.tabs = [{
  		tab.template="main.html",
  		tab.controller="MainCtrl"
	}];

}]);

About

Directive allows you to dynamically specify a controller name to inject into html template

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published