angularjs-controller

Retrieving data out of post success from separate controller angularjs

☆樱花仙子☆ 提交于 2019-12-02 10:21:42
I am writing a simple service that uploads a file and posts it to a Spring controller. The controller manipulates this data and returns several objects as JSON. I am working with the following Angular service: myApp.service('fileUpload', [ '$http', function($http) { this.uploadFileToUrl = function(file, uploadUrl) { var fd = new FormData(); fd.append('file', file); $http.post(uploadUrl, fd, { transformRequest : angular.identity, headers : { 'Content-Type' : undefined } }) .success(function(data) { console.log("upload successful") //console.log(data) namesandaddresses = data; }) .error(function

Argument 'indexController' is not a function, got undefined

大兔子大兔子 提交于 2019-12-02 09:25:29
问题 This has been asked before but it didn't answer my question. I am pretty new to angular and I am just putting things together at the moment. I am trying to get my factory to work inside my controller. However I keep getting the following error in my console: Argument 'indexController' is not a function, got undefined I am broke the services and controller in different directories and I have added the service and controller <script> to the index.html file. I am using IntelliJ and used its plug

How directives are invoked If an element that contains a directive is added dynamically through an angular controller?

一曲冷凌霜 提交于 2019-12-02 07:56:00
问题 After doing some search I haven't found much information in this bad practice. Let's say I have a controller that behaves like that (I know it should have been a directive and that in controllers we never do DOM manipulation but I am curious..) angular.module('app').controller('test', ['$scope', function($scope) { $scope.addElement = function() { var input = document.createElement('input'); input.type = "text"; //directive input.setAttribute("autosize","autosize"); input.setAttribute("ng

How to inject parameters into an inline controller function in $uibModal

孤街醉人 提交于 2019-12-02 07:47:50
I'm having a problem with $uibModal's open function, specifically injecting my parameters properly into an inline controller function. Being the angularjs noob that I am, I've tried several things, none of which I can get to work. I'm using Visual Studio Code to write the angular, and gulp to build it. My first attempt (using an inline function): var modalInstance = $uibModal.open({ animation: false, templateUrl: 'app/workform/LoanActions/LoanActionOverpay.modal.html', controller: function ($scope, $uibModalInstance) { $scope.showOverpay = true; $scope.OverpayAccount = function () { $scope

Where should I place code to be used across components/controllers for an AngularJS app?

僤鯓⒐⒋嵵緔 提交于 2019-12-02 06:27:17
Should it be associated with the app module? Should it be a component or just a controller? Basically what I am trying to achieve is a common layout across all pages within which I can place or remove other components. Here is what my app's structure roughly looks like: -/bower_components -/core -/login --login.component.js --login.module.js --login.template.html -/register --register.component.js --register.module.js --register.template.html -app.css -app.module.js -index.html This might be a bit subjective to answer but what I personally do in a components based Angular application is to

How directives are invoked If an element that contains a directive is added dynamically through an angular controller?

蹲街弑〆低调 提交于 2019-12-02 06:16:52
After doing some search I haven't found much information in this bad practice. Let's say I have a controller that behaves like that (I know it should have been a directive and that in controllers we never do DOM manipulation but I am curious..) angular.module('app').controller('test', ['$scope', function($scope) { $scope.addElement = function() { var input = document.createElement('input'); input.type = "text"; //directive input.setAttribute("autosize","autosize"); input.setAttribute("ng-model","dummy"); //[ append code ] input.focus(); } } ]); and let's assume that I have a button that

Argument 'indexController' is not a function, got undefined

偶尔善良 提交于 2019-12-02 05:13:21
This has been asked before but it didn't answer my question. I am pretty new to angular and I am just putting things together at the moment. I am trying to get my factory to work inside my controller. However I keep getting the following error in my console: Argument 'indexController' is not a function, got undefined I am broke the services and controller in different directories and I have added the service and controller <script> to the index.html file. I am using IntelliJ and used its plug-in to create the boilerplate. <body > <ul class="menu"> <li><a href="#/view1">view1</a></li> <li><a

Communicating between controllers in AngularJs

谁都会走 提交于 2019-12-02 04:56:25
问题 I have a simple question: what's the best ('cleanest', 'scaleable') path one should go when it comes to interact between (let's say) two controllers. Would that be to define a service and watch that service's return-value in order to react? I setup a simple example here, where I watch the service's current value: $scope.$watch( function() { return myService.getValue(); }, function(newVal) { $scope.value1 = newVal; }); and update that service's value when one of the buttons is clicked. Can

Add new text box on click of a button in angular js

大城市里の小女人 提交于 2019-12-02 04:17:39
问题 How do I add new text box when submit button is pushed. This is what I have tried and I know there's some thing wrong. I am still new to angular js. Example: <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Example - example-ngController-production</title> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script> <script> angular.module('controllerAsExample', []).controller('SettingsController1', function ($scope) { $scope.contacts=[] $scope

Add new text box on click of a button in angular js

不想你离开。 提交于 2019-12-02 03:33:43
How do I add new text box when submit button is pushed. This is what I have tried and I know there's some thing wrong. I am still new to angular js. Example: <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Example - example-ngController-production</title> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script> <script> angular.module('controllerAsExample', []).controller('SettingsController1', function ($scope) { $scope.contacts=[] $scope.addContact = function() { $scope.contact.push({$scope.contact}) } }); }; </script> </head> <body ng-app=