小编use*_*508的帖子

在上传Angularjs之前预览图像

嗨我想知道在使用angularjs上传它们之前是否有预览图像的方法?我正在使用这个库.https://github.com/danialfarid/angular-file-upload

谢谢.这是我的代码:

template.html

 <div ng-controller="picUploadCtr">
<form>
        <input type="text" ng-model="myModelObj">
      <input type="file" ng-file-select="onFileSelect($files)" >
 <input type="file" ng-file-select="onFileSelect($files)" multiple>

 </form>
     </div>
Run Code Online (Sandbox Code Playgroud)

controller.js

  .controller('picUploadCtr', function($scope, $http,$location, userSettingsService) {

 $scope.onFileSelect = function($files) {
//$files: an array of files selected, each file has name, size, and type.
for (var i = 0; i < $files.length; i++) {
  var $file = $files[i];
  $http.uploadFile({
    url: 'server/upload/url', //upload.php script, node.js route, or servlet uplaod url)
    data: {myObj: $scope.myModelObj},
    file: $file
  }).then(function(data, status, headers, config) {
    // file …
Run Code Online (Sandbox Code Playgroud)

ajax upload file-upload angularjs angularjs-directive

49
推荐指数
4
解决办法
8万
查看次数

angularjs文本区域字符计数器

嗨,我有一个文本区域的characeter计数器.我的问题是它不计算空格或换行符.我该怎么做才能这样做?

   <div class="controls">

   <textarea rows="4" cols="50"  maxlength="1500" data-ng-minLength="1" data-ng  
    model="createprofilefields.description" required highlight-on-
    error></textarea>

    <br />

<!--counter-->
  <span class="form-help">{{1500-createprofilefields.description.length}}         
   Characters</span>

    </div>
Run Code Online (Sandbox Code Playgroud)

angularjs angular-ui angularjs-directive angularjs-ng-repeat

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

如何在AngularJS中读取文件?

是否可以读取AngularJS中的文件?我想将文件放入HTML5画布中进行裁剪.

我在考虑使用指令?这是我想要放入我的指令的javscript代码:

function readURL(input) {

    if (input.files && input.files[0]) {
        var reader = new FileReader();

        reader.onload = function (e) {
            $('#blah').attr('src', e.target.result);
        }

        reader.readAsDataURL(input.files[0]);
    }
}
Run Code Online (Sandbox Code Playgroud)

javascript canvas filereader angularjs

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

格式化电话号码的指令

我想知道如何使用angularjs指令自动格式化输入字段中的数字?当我输入输入字段时说6042919283我希望它显示为604-291-9283.

谢谢

angularjs angularjs-directive angularjs-scope angularjs-ng-repeat angular-ui-bootstrap

13
推荐指数
3
解决办法
4万
查看次数

自动滚动angularjs

嗨,我正在创建一个带有angularjs的聊天应用程序,当用户向另一个用户发送消息时,它会自动向下滚动.我不知道如何实现这个,因为我的聊天窗口是一个固定的ul元素.我想我需要实现一个指令来执行此操作(在ul元素上使用inboxmsg-scroll)

有帮助吗?谢谢.

HTML

<ul class="chatting-window" inboxmsg-scroll>
    <li data-ng-repeat="messageinfo in messages">
        <div class="message-date">
            {{messageinfo[0]}}
        </div>
    </li>
</ul>
Run Code Online (Sandbox Code Playgroud)

javascript jquery autoscroll angularjs angularjs-directive

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

laravel route过滤器来检查用户角色

我正在laravel 4中构建一个restful api,其中有许多用户拥有不同类型的权限.我想根据用户角色(保存在db中的用户表中)限制对不同路由的访问

我该怎么办?这是我到目前为止所做的(到目前为止还没有工作).

filters.php

//allows backend api access depending on the user's role once they are logged in
Route::filter('role', function()
{ 
return Auth::user()->role;
}); 
Run Code Online (Sandbox Code Playgroud)

routes.php文件

 Route::group(array('before' => 'role'), function($role) {
 if($role==1){
        Route::get('customer/retrieve/{id}', 'CustomerController@retrieve_single');
        Route::post('customer/create', 'CustomerController@create');
        Route::put('customer/update/{id}', 'CustomerController@update');
 }

    });
Run Code Online (Sandbox Code Playgroud)

我是否有可能为"组过滤器"编写错误的语法?

php laravel laravel-4 laravel-routing

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

部署时aws beanstalk 403错误

嗨,我正在使用亚马逊网络服务弹性豆茎.每次我使用git aws.push,我的php应用程序成功上传但是,当我点击它说的网址时

Forbidden

You don't have permission to access / on this server.
Run Code Online (Sandbox Code Playgroud)

我的服务器规格:

运行PHP 5.4的64位Amazon Linux 2014.03 v1.0.2

会导致什么?谢谢

git amazon-s3 amazon-ec2 amazon-web-services amazon-elastic-beanstalk

8
推荐指数
1
解决办法
9191
查看次数

当模型改变时,angularjs图像src会发生变化

我正在服务器上旋转图像,我想知道如何在我的页面上显示图像更改?

我想我必须使用$ scope.$ apply()但每次我使用它时都会收到错误消息"正在进行摘要循环"

template.html

 < img src='{{tempimagefilepath}}/> <!--image-->
Run Code Online (Sandbox Code Playgroud)

controller.js

 photoalbumServ.rotate_photo(post).then(function(data) {
  //after server modifies photo
    $scope.tempimagefilepath = $scope.baseurl + "user_images/user_43/temp/123-temp.jpg";
     $scope.$apply();
    });
Run Code Online (Sandbox Code Playgroud)

谢谢

解:

我的解决方案是更改范围值{{tempimagefilepath}},以便图像更改.这要求我在旋转图像时不断重命名服务器上的文件.

javascript angularjs angularjs-directive angularjs-scope

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

laravel multiple循环中的where子句

我希望查询能够选择25岁以上且150-170cm或190-200cm之间的所有用户记录.

我在下面写下了这个查询.然而问题是它不断得到25岁的人或190-200厘米的人而不是25岁的150-170岁或25岁的人,身高190-200厘米.我怎样才能解决这个问题?谢谢

 $heightarray=array(array(150,170),array(190,200));
 $user->where('age',25);

   for($i=0;$i<count($heightarray);i++){
 if($i==0){
   $user->whereBetween('height',$heightarray[$i])
}else{
   $user->orWhereBetween('height',$heightarray[$i])
 }
 }
      $user->get();
Run Code Online (Sandbox Code Playgroud)

编辑:我尝试过高级版(http://laravel.com/docs/queries#advanced-wheres)并且它对我不起作用,因为我无法将$ heightarray参数传递给闭包.

来自laravel文档

 DB::table('users')
        ->where('name', '=', 'John')
        ->orWhere(function($query)
        {
            $query->where('votes', '>', 100)
                  ->where('title', '<>', 'Admin');
        })
        ->get();
Run Code Online (Sandbox Code Playgroud)

php mysql laravel laravel-4

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

如何在laravel 4中批量更新

嗨,我想知道如何在laravel 4中进行批量更新,而不是循环和更新块?

我知道批量插入是这样的:

$invoiceitem->insert($items_array);
Run Code Online (Sandbox Code Playgroud)

php mysql laravel eloquent laravel-4

6
推荐指数
1
解决办法
4183
查看次数