- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 09:40 PM
I have tried this functionality in a widget.
HTML Template:
<div>
Click on Button:
<button ng-click="fun()">
Click on me
</button>
</div>
Client script:
function($scope) {
var c = this;
$scope.fun=function()
{
alert("hello world");
}
}
It works well with above code. But instead of ng-click directive,I used onclick() event but it won't work with it?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 11:33 PM
Hi,
Below link will helps you on your requirement.
https://community.servicenow.com/community?id=community_question&sys_id=a52e9a061bb01910aefc11751a4bcb34
Opening thread will not be a good thing once your issue got fixed and If my response helped please mark it correct and close the thread so that others get benefit in future.
Thanks,
Pavankumar
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 09:55 PM
Hi Tejas,
Using onClick() will not work if you are writing function in client script
You need to use ng-click only to call function
Please refer below example where you can use onClick() using script tag
<div>
Click on Button:
<button onClick="test()">
Click on me
</button>
<script>
function test(){
alert("test");
}
</script>
</div>
Thanks,
Valmik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2022 05:43 AM
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 11:01 PM
Hi,
Refer below link.
https://community.servicenow.com/community?id=community_question&sys_id=a52e9a061bb01910aefc11751a4bcb34
Hope it helps!!
Please Mark ✅ Correct if applicable, Thanks!!
Regards
Pavankumar
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 11:33 PM
Hi,
Below link will helps you on your requirement.
https://community.servicenow.com/community?id=community_question&sys_id=a52e9a061bb01910aefc11751a4bcb34
Opening thread will not be a good thing once your issue got fixed and If my response helped please mark it correct and close the thread so that others get benefit in future.
Thanks,
Pavankumar
ServiceNow Community MVP 2024.
Thanks,
Pavankumar