I want to pass a JSON string to ng-click
here is the JSON string:
{"id":0,"parentID":0,"SubMenuItems":[],"imageName":"Icon.png","moduleName":"No Menu"}
HTML:
<!DOCTYPE html> <html> <head> <script data-require=" angular.js@ *" data-semver="1.4.0-beta.4" src="https://code.angularjs.org/1.4.0-beta.4/angular.js"></script> <link rel="stylesheet" href="style.css" /> <script src="script.js"></script> </head> <body ng-app="app" ng-controller="appCtrl"> <h1>Hello Plunker!</h1> <button ng-click="go({ "id": 0, "parentID": 0, "SubMenuItems": [], "imageName": "Icon.png", "moduleName": "No Menu" })">GOOOOOOOOOOOOOO!!!!!!!!!!</button> </body> </html>
JS: // The code goes here
var app = angular.module('app', []); app.controller('appCtrl', ['$scope', function($scope) { $scope.go = function(parm) { alert('hi'); }; } ]);
Plunker
source share