我有一个包含值列表的数组.
[Object { id="5", country="UAE"}, Object { id="4", country="India"}]
Run Code Online (Sandbox Code Playgroud)
我想根据id中的值获取数组项的索引.如何在angularJS控制器中获取值为id = 4的数组项的索引位置?
我有一个表单只使用angularJS上传图像文件.上传文件一切正常.问题是,我想将上传的文件限制为仅图像文件,并将图像的大小限制为一些MB.如何仅使用angularJS实现此目的?下面是代码
$scope.uploadFile = function(files) {
var fd = new FormData();
//Take the first selected file
fd.append("file", files[0]);
$http.post("logoTypesServiceStore", fd, {
withCredentials: true,
headers: {'Content-Type': undefined },
transformRequest: angular.identity
}).success( function(data) {alert(data); }).error( function(data) { alert(data)});
};
Run Code Online (Sandbox Code Playgroud)
以下是上传文件的表格.
<form name="logoTypeForm" novalidate>
<input type="text" name="logoType" ng-model="logoType" class="form-control" required />
<input type="file" name="file" onchange="angular.element(this).scope().uploadFile(this.files)"/>
</form>
Run Code Online (Sandbox Code Playgroud) 我曾经用于Paginator::make
对表中的记录进行分页.在视图中,我正在获取分页链接,但每个链接都包含其中的所有记录.如何将其限制为perPage
项目?
$datas = Paginator::make($paginator, count($paginator), $perPage);
return $datas;
Run Code Online (Sandbox Code Playgroud)
代码输出:
{"total":10,"per_page":5,"current_page":1,"last_page":2,"from":1,"to":5,"data":
[{"id":"10","languages":"ds","created_at":"2014-05-23
11:59:02.000","created_by":"1","updated_at":"2014-05-23
11:59:02.000","updated_by":"1","is_active":"1"},
{"id":"9","languages":"urdu","created_at":"2014-05-23
11:57:24.000","created_by":"1","updated_at":"2014-05-23
11:57:24.000","updated_by":"1","is_active":"1"},
{"id":"8","languages":"were","created_at":"2014-05-23
11:55:49.000","created_by":"1","updated_at":"2014-05-23
11:55:49.000","updated_by":"1","is_active":"1"},
{"id":"7","languages":"delete","created_at":"2014-05-23
11:54:57.000","created_by":"1","updated_at":"2014-05-24
06:02:46.000","updated_by":"1","is_active":"1"},
{"id":"6","languages":"sdf","created_at":"2014-05-23
11:53:11.000","created_by":"1","updated_at":"2014-05-23
11:53:11.000","updated_by":"1","is_active":"1"},
{"id":"5","languages":"dada","created_at":"2014-05-23
11:51:33.000","created_by":"1","updated_at":"2014-05-24
05:44:34.000","updated_by":"1","is_active":"1"},
{"id":"4","languages":"English","created_at":"2014-05-23
11:49:49.000","created_by":"1","updated_at":"2014-05-23
11:49:49.000","updated_by":"1","is_active":"1"},
{"id":"3","languages":"asdfgf","created_at":"2014-05-23
11:48:20.000","created_by":"1","updated_at":"2014-05-23
11:48:20.000","updated_by":"1","is_active":"1"},
{"id":"2","languages":"Tamil","created_at":"2014-05-23
10:55:50.000","created_by":"1","updated_at":"2014-05-23
10:55:50.000","updated_by":"1","is_active":"1"},
{"id":"1","languages":"Tamil","created_at":"2014-05-23
10:51:42.000","created_by":"1","updated_at":"2014-05-26
04:41:27.000","updated_by":"1","is_active":"1"}]}
Run Code Online (Sandbox Code Playgroud) 我的路线:
Route::group(array("namespace" => "languages"),function(){
Route::resource("languagesService", "languageServiceController");
Route::resource("languages","languageController");
});
Run Code Online (Sandbox Code Playgroud)
languageservicecontroller和languagecontroller是子文件夹语言.
在登录尝试期间,我保存了用户名和密码
Session::put('username', $user['username']);
Session::put('password', $user['password']);
Run Code Online (Sandbox Code Playgroud)
但是当我尝试从languageController中检索时
$username = Session::get('username');
$password = Session::get('password');
Run Code Online (Sandbox Code Playgroud)
我得到了以下错误
"类'语言\会话'未找到".