Game In Phaser - Javascript And Events In Angularjs
How can I execute an AngularJs method from plain javascript? myApp.controller('someController',['$scope',function($scope){ //Some code was here $scope.a = valueA; $scope.b =
Solution 1:
Finally I have a solution,
var intermediary;
myApp.controller("someController", ["$scope",function($scope){
intermediary = function(fn){
var phase = $scope.$root.$$phase;
var value;
if(phase == '$apply' || phase == '$digest') {
if(fn && (typeof(fn) === 'function')) {
value = fn();
if(value){
$scope.valIntermediary = value;
}
}
} else {
$scope.$apply(function() {
value = fn();
if (value) {
$scope.valIntermediary = value;
}
});
}
};
$scope.$watch("valIntermediary",function(){
//Do something whit a value var inside my controller
});
}]};
if(intermediary){
intermediary(function(value) {
return { /*Some data when click is true*/}
})
}
Post a Comment for "Game In Phaser - Javascript And Events In Angularjs"