Anoop
Anoop

Reputation: 23208

How to add content dynamically using angularjs

I have two columns on my page.

Left column has list of add button and right column is empty.

I want add append content to right side based on button click(left side buttons).

These content must be rendered using Angular (using angular binding) before appending to the DOM.

I search a lot but did't got satisfying info.

I am new to AngularJS.

Example:

content is

 <tr>
    <td> <input type="checkbox" name="name1" value={{name}}> </td>
    <td> {{ text }} </td>
</tr>

I want add above tr in right side column (which have empty table initially).

Upvotes: 1

Views: 1013

Answers (1)

maxisam
maxisam

Reputation: 22715

I would suggest you use ng-view and route to achieve this.

Here is the plunker

var app = angular.module('plunker', [])
.config(['$routeProvider', function ($routeProvider) {
    $routeProvider.when('/btnA', { templateUrl: 'btnA.html', controller: btnACtrl })

                            .otherwise({ redirectTo: '/btnB' });
          }]);

function btnACtrl($scope){
   $scope.text = 'Hello world !' ;
}

Upvotes: 1

Related Questions