4

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?

12
  • $compile(str)($scope); This is the syntax you have written. Could you tell me that your controller js is already loaded? Commented Feb 21, 2019 at 4:23
  • Just try to use a simple string <a>...ReadMore</a> Is it ok? Commented Feb 21, 2019 at 4:24
  • i need ng-click directive to capture the click event Commented Feb 21, 2019 at 4:48
  • For test cases, compile the string <a>...ReadMore</a>, Let me know is it ok? Commented Feb 21, 2019 at 5:53
  • @Shohel yes compiling just the string <a> produces no error Commented Feb 21, 2019 at 6:03

1 Answer 1

1

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.