$scope.showtbleoption = function(id)
{
console.log(id);
$("#showoption").empty();
$("#showoption").append('<button class="btn btn-info" ng-click="editrc(id)">');
};
how to call editrc() function in angularjs controller ?
$scope.showtbleoption = function(id)
{
console.log(id);
$("#showoption").empty();
$("#showoption").append('<button class="btn btn-info" ng-click="editrc(id)">');
};
how to call editrc() function in angularjs controller ?
On
Instead of appending using jQuery, use $compile service to bind it to dom. Like this:
$scope.domEle = $compile('<button class="btn btn-info" ng-click="editrc(id)">')
and in HTML call like this:
{{ domeEle }}
And in controller define editrc function like this:
$scope.editrc = function(val){
}
On
You can use the ng-bind-html directive to bind the html's to the template dynamically . You will however have to compile the html using $compile by doing $compile(<html>) . Any expressions mentioned in the compiled html could call the definitions you provide in the controller .
Appending raw DOM with jQuery would make angular directive compile. You have to use
$compileservice, by which you will be$compilethat DOM first & then inject that DOM in DOM tree.$compileis API function(returns function) which ask for DOM, then you can again call that function by passing$scopeto evaluate against particularcontext.$compileAPI method will take care of compiling all directives on DOM & updatebindings.In below case
idvalue wouldn't be available inside$scopedirectly, you could either store it in a scope variable or pass it by string concatenation.