I've my Web page structured with AngularJs that hosting a Silverlight Control. Now I need to call a function placed in a controller angular from silverlight. This is my 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 this is the code in my Silverlight viewModel:
public class ViewModel : ViewModelBase, INotifyDataErrorInfo
{
public void CallAngularMethod()
{
HtmlPage.Window.Invoke("testMethodForSilverlight ", new[] { "Testing" });
}
}
Unfortunately when I call the method the error returned is ("Failed to invoke: testMethodForSilverlight" ). Does anyone have any idea?