angularjs - Updating a controller's scope using a directive's method -


how can use method in directive update variable in controller's scope?

i using: dropzone.js , angular-dropzone.js.

one of dropzone's methods .getqueuedfiles(). use method update variable in controller scope, isn't working. able update controller scope can show , hide things , pass number of files next step in form.

here angular:

.controller('imagesctrl', function($scope) {    $scope.queuedfiles = 0;    $scope.dropzoneconfig = {     init: function() {       this.on("addedfile", function(file) {         $scope.queuedfiles = $scope.dropzone.getqueuedfiles().length;       });     }   };  }) 

and here html:

<form class="dropzone clear"     method="post"     enctype="multipart/form-data"     ng-dropzone     dropzone="dropzone"     dropzone-config="dropzoneconfig"> </form>  <div>queued files: {{queuedfiles}}</div> 

this correct code

var app = angular.module('myapp', ['ui.router', 'myapp.controllers']).     config(['$stateprovider', '$urlrouterprovider',     function ($stateprovider, $urlrouterprovider) {         $urlrouterprovider.otherwise('/');          $stateprovider         .state('app', {             url: '/',             templateurl: 'admin.html',             onenter: function ($stateparams) {                 console.log("entered admin route");             }             //controller: 'mycontroller'         })         .state('sitebinding', {             url: '/sitebinding',             templateurl: 'sitebinding.html'         })         .state('scrum', {             url: '/scrum',             templateurl: 'scrum.html'         });       } ]);   angular.module('myapp.controllers', []). controller('mycontroller', function ($scope) {     $scope.models = {         helloangular: 'i work!'     };      $scope.$on('$statechangestart', function (evt, tostate, toparams, fromstate, fromparams) {         console.log('in state change start');     }) }); 

this problem: when write angular.module('myapp', []) specifying dependencies second time define controllers, override original module.

if want add new stuff existing module don't need pass dependencies array

angular.module('mymodule').controller('myctrl', function....


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -