1

The onclick event on the return template doesn't do anything

{
    field: '',
    title: '',
    width: '80px',
    template: function (record) {
        return (
            '  <a href="javascript:void(0);" class="btn btn-xs btn-success margin-top-5 margin-bottom-5 btn-lg, btn-sucess"  ng-class="btnClass" ng-click="console.log(record)"> <span>Add</span> </a>'
        );
    }
},

Tried changing the string of the a tag, still unable to call ng-click method.

4
  • Where and how is this object used? Commented Dec 9, 2022 at 8:24
  • Perhaps delegation is an idea Commented Dec 9, 2022 at 8:28
  • @mplungjan is is used part of a bigger object for options on a kendo grid Commented Dec 9, 2022 at 8:42
  • I suggested delegation. Commented Dec 9, 2022 at 9:06

1 Answer 1

1

You have "javascript:void(0)" which is a function in JavaScript that returns undefined. When you click it it wont do anything. Just change href="#" Also update the ng-click to prevent default:

href="#" ng-click="$event.preventDefault();console.log(record)"

For more information: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void

Sign up to request clarification or add additional context in comments.

6 Comments

so is the ngClick not necessary , can I add a console log at the href
You can use that, but make sure to remove javascript:void(0) because it overrides ng-click. Or just use href="#"
still not working
appologies how can I make something like this work '<button ng-Click="console.log("someString")">test</button>'
having trouble with where to add the quotation marks
|

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.