Search code examples
javascripthtmlangularjsdynamic-html

Unable to compile Dynamic Html using $compile


I am trying to add dynamic html to my code using below lines

var el = $compile('<a ng-controller=\"tableController\" ng-click=\"open\">...ReadMore</a>')($scope);

However it is producing the below error enter image description here

Can anyone help?


Solution

  • You missed the parentheses of the open method, The following code should be work.

    var el = $compile('<a ng-controller=\"tableController\" ng click=\"open()\">...ReadMore</a>')($scope);