我正在尝试根据给定的示例使用带角度的云计算
加载页面时,我可以看到两个 console.log() 都打印了,但是当我上传文件时,什么也没有发生。我没有收到任何控制台错误,也没有打印我在 $watch 中添加的 console.log()。我在这里做错什么了吗?
我们也可以从链接的示例中看到,这个上传按钮添加了一个点击事件,这不是我的情况,是问题吗?
我的应用是
var myApp = angular.module('myApp', [
'ngRoute', 'ngResource', 'ngInflection', 'templates',
'cloudinary','angularFileUpload'])
我的控制器是
myApp.controller('LocationUpdate', ['$scope', '$rootScope',
'$resource', '$http', '$location', '$routeParams', '$upload',
function($scope, $rootScope, $resource, $http, $location,
$routeParams, $upload){
console.log("in controller");
// here i have added a listener which is not getting invoked
$scope.$watch('files', function() {
console.log('in watcher');
}
}]);
我在haml中的模板代码是
#direct_upload{"ng-file-drag-over-class" => "", "ng-file-drop" => "", "ng-model" => "files", "ng-multiple" => "true"}
.upload_button_holder
.upload_button{:href => "#", "ng-file-select" => "", "ng-model" => "files", "ng-multiple" => "true", :resetonclick => "true", :title => "upload"} Upload
我的 application.js 是
//= require jquery
//= require jquery_ujs
//
//= require cloudinary
//= require jquery.cloudinary
//= require angular-file-upload-shim.min
//= require angular
//= require angular-animate
//= require angular-route
//= require angular-resource
//= require angular.cloudinary
//= require angular-file-upload.min
//= require ./angular-ui-router.min
//= require angular-sanitize
//= require angular-ui-bootstrap
//= require angular-ui-bootstrap-tpls
//= require angular-rails-templates
//= require angular/my_app
//= require_tree .
$.cloudinary.config().cloud_name = 'XXXXXXX';
$.cloudinary.config().upload_preset = 'XXXXXX';