JSFiddle - React, Tailwind, and code Playground
by Yang Tyler
HTML
<div ng-app="myApp">
<div ng-controller="testController">
<span>{{myText}}</span> <br/>
<button ng-click="test()">Start!!!</button>
</div>
</div>
JavaScript
var myApp = angular.module("myApp", []);
myApp.controller("testController", function($scope, myFactory){
$scope.myText = "hello!";
$scope.test = function(){
myFactory.show($scope, function(){
//alert("it work!!!!");
console.log("it works!");
});
}
});
myApp.factory("myFactory", function(mockDialog){
function _show(scope, callback){
mockDialog.popup({
scope: scope,
onTap: function(e){
scope.myText = "it works!"; // not $scope
callback();
}
})
}
return {
show: _show
};
});
myApp.factory("mockDialog", function(){
function _popup(params){
params&¶ms.onTap&¶ms.onTap();
}
return {
popup: _popup
}
});