小编Rob*_*man的帖子

Angularjs监视服务对象

为什么我不能在服务中观看对象.我有一个简单的变量工作,但一个对象不起作用. http://plnkr.co/edit/S4b2g3baS7dwQt3t8XEK?p=preview

var app = angular.module('plunker', []);

app.service('test', ['$http', '$rootScope',
            function ($http,   $rootScope) {

  var data = 0;
  var obj  = {
                "data": 0
              };

  this.add = function(){
    obj.data += 1;
    console.log('data:', obj);
  };

  this.getData     = function() { return obj; };

}]);

app.controller('TestController', ['$scope', '$rootScope', '$filter', 'test',
                          function($scope,   $rootScope,   $filter,   test) {

  //test controller
  $scope.add = function(){
    test.add();
  };
  $scope.test = test;
  $scope.$watch('test.getData()', function(newVal){
    console.log('data changes into: ', newVal)
  });
}]);
Run Code Online (Sandbox Code Playgroud)

service watch angularjs

11
推荐指数
2
解决办法
2万
查看次数

Laravel迁移取消了

当我尝试迁移某些内容时,我收到此错误:

**************************************
*     Application In Production!     *
**************************************

Do you really wish to run this command?
Command Cancelled!
Run Code Online (Sandbox Code Playgroud)

我正在运行没有Plesk 12的centOS6.6服务器无论如何都要弄清楚错误是什么或如何解决它?

谢谢

php migration laravel artisan

3
推荐指数
3
解决办法
4235
查看次数

Javascript set/clearinterval不起作用

如何在javascript中停止间隔?

为什么间隔不停?

setInterval(alarm, 500);
window.clearInterval(alarm);
Run Code Online (Sandbox Code Playgroud)

还尝试过:

window.setInterval(alarm, 500);
window.clearInterval(alarm);
Run Code Online (Sandbox Code Playgroud)

总是同样的问题:(

仍然不起作用:

var switc = 1;
getValue();
function getValue (){
if(switc == 1){
    var myTimer = window.setInterval(alarm, 500);
}
else if(switc == 0){
    window.clearInterval(myTimer);
}
}
function alarm(){
    console.log("test");
}
Run Code Online (Sandbox Code Playgroud)

javascript

2
推荐指数
1
解决办法
2万
查看次数

使用$ this的Laravel 4类函数调用错误

我想使用函数addMenu和菜单,但我收到此错误:

Using $this when not in object context
Run Code Online (Sandbox Code Playgroud)

我做错什么了吗?还是有另一种方法来调用这些功能?
我的代码:

class Documentation {
    protected $app;
    protected $menu = [];

    public function __construct(Application $app){
        $this->app = $app;
        $this->addMenu(["Hello world"]);

    }
    public static function addMenu($item){
        $this->menu[] = $item;
    }
    public static function menu(){
        return $this->menu;
    }
}
Run Code Online (Sandbox Code Playgroud)

php class laravel laravel-4

0
推荐指数
1
解决办法
63
查看次数

标签 统计

laravel ×2

php ×2

angularjs ×1

artisan ×1

class ×1

javascript ×1

laravel-4 ×1

migration ×1

service ×1

watch ×1