发表于: 2016-12-27 01:30:02
3 1672
今天完成的事情:使用slice和$watch完成了分页的功能完成了任务八,研究了下项目用的那种分页方式,但是没有后端的数据无法实现,复习了下关于angular路由、模块和依赖注入,使用npm安装了angular-file-upload。
明天的计划:结合实例研究下angular file-upload的使用方法,研究下formdata。
遇到的问题:在实现分页功能的时候,使用的主要是js的slice方法,不够angular。angular的自定服务不太会设置,感觉注入和数据的提取还需要练习。
收获:从师兄那学到了使用命令行自动重启nginx的方法,了解了项目中使用的分页方法。朋友要来线下了。
angular file-upload的官方文档
Properties
- url
{String}
: Path on the server to upload files - alias
{String}
: Name of the field which will contain the file, default isfile
- queue
{Array}
: Items to be uploaded - progress
{Number}
: Upload queue progress percentage. Read only. - headers
{Object}
: Headers to be sent along with the files. HTML5 browsers only. - formData
{Array}
: Data to be sent along with the files - filters
{Array}
: Filters to be applied to the files before adding them to the queue. If the filter returnstrue
the file will be added to the queue - autoUpload
{Boolean}
: Automatically upload files after adding them to the queue - method
{String}
: It's a request method. By defaultPOST
. HTML5 browsers only. - removeAfterUpload
{Boolean}
: Remove files from the queue after uploading - isHTML5
{Boolean}
:true
if uploader is html5-uploader. Read only. - isUploading
{Boolean}
:true
if an upload is in progress. Read only. - queueLimit
{Number}
: maximum count of files - withCredentials
{Boolean}
: enable CORS. HTML5 browsers only.
Methods
- addToQueue
function(files[, options[, filters]]) {
: Add items to the queue, wherefiles
is a{FileList|File|HTMLInputElement}
,options
is an{Object}
andfilters
is a{String}
. - removeFromQueue
function(value) {
: Remove an item from the queue, wherevalue
is{FileItem}
or index of item. - clearQueue
function() {
: Removes all elements from the queue. - uploadItem
function(value) {
: Uploads an item, wherevalue
is{FileItem}
or index of item. - cancelItem
function(value) {
: Cancels uploading of item, wherevalue
is{FileItem}
or index of item. - uploadAll
function() {
: Upload all pending items on the queue. - cancelAll
function() {
: Cancels all current uploads. - destroy
function() {
: Destroys a uploader. - isFile
function(value) {return {Boolean};}
: Returns true if value is{File}
. - isFileLikeObject
function(value) {return {Boolean};}
: Returns true if value is{FileLikeObject}
. - getIndexOfItem
function({FileItem}) {return {Number};}
: Returns the index of the{FileItem}
queue element. - getReadyItems
function() {return {Array.<FileItems>};}
: Return items are ready to upload. - getNotUploadedItems
function() {return {Array.<FileItems>};}
: Return an array of all pending items on the queue
Callbacks
- onAfterAddingFile
function(item) {
: Fires after adding a single file to the queue. - onWhenAddingFileFailed
function(item, filter, options) {
: When adding a file failed. - onAfterAddingAll
function(addedItems) {
: Fires after adding all the dragged or selected files to the queue. - onBeforeUploadItem
function(item) {
: Fires before uploading an item. - onProgressItem
function(item, progress) {
: On file upload progress. - onSuccessItem
function(item, response, status, headers) {
: On file successfully uploaded - onErrorItem
function(item, response, status, headers) {
: On upload error - onCancelItem
function(item, response, status, headers) {
- On cancel uploading - onCompleteItem
function(item, response, status, headers) {
: On file upload complete (independently of the sucess of the operation) - onProgressAll
function(progress) {
: On upload queue progress - onCompleteAll
function() {
: On all loaded when uploading an entire queue, or on file loaded when uploading a single independent file
评论