c# - Call angular js method by silverlight control -
i've web page structured angularjs hosting silverlight control. need phone call function placed in controller angular silverlight. controller angular code sample:
var mymodule= angular.module('mymodule', []); mymodule.controller('maincontroller', ['$rootscope', '$scope', '$http', function ($rootscope, $scope, $http) { var _self = this; _self.testmethodforsilverlight = function (message) { alert("message: " + message); }; }]);
and code in silverlight viewmodel:
public class viewmodel : viewmodelbase, inotifydataerrorinfo { public void callangularmethod() { htmlpage.window.invoke("testmethodforsilverlight ", new[] { "testing" }); } }
unfortunately when phone call method error returned ("failed invoke: testmethodforsilverlight" ). have idea?
you can seek writing custom javascript code , this
<script type="text/javascript"> function callangularfunc(message) { angular.element($("#elementid")).scope().testmethodforsilverlight(message); } </script>
here, elementid dom element angular controller bound to.
there more info related accessing angular info outside in post.
then, in silverlight code, create phone call this
public class viewmodel : viewmodelbase, inotifydataerrorinfo { public void callangularmethod() { htmlpage.window.invoke("callangularfunc", new[] { "testing" }); } }
c# angularjs silverlight
No comments:
Post a Comment