The AngularJS controller exposes the data that is to be displayed into the html view. It plays the essential role of the ModelView in the MVVM design pattern. The view is a part of the HTML template.
0
votes
2answers
29 views
Triggering angular form validation from a click handler
I have a form that was moved into a table, losing the built in form validation features as I cannot use ng-submit:
<tr ng-form="controller.add.form">
<td>New item</td>
...
2
votes
2answers
80 views
How to do load page in Angular JS?
How to load content on page by clicking on menu links?
For example, there is menu:
<a href="#">Personal</a>
<a href="#">Contacts</a>
Question is in how change template HTML ...
106
votes
8answers
55k views
AngularJS : The correct way of binding to a service properties
I’m looking for the best practice of how to bind to a service property in AngularJS.
I have worked through multiple examples to understand how to bind to properties in a service that is created using ...
0
votes
2answers
30 views
AngularJS: What's the correct syntax to share a factory service among custom directives with controllers?
I've 2 custom directives and a controller that all need to share some data. The following doesn't compile. What's the correct syntax to do this?
flight-service.js (shared):
(function() {
var app = ...
0
votes
2answers
10 views
AngluarJS filter table population by user id
I'm trying to filter a GET call by user id. I keep getting an error that says the userId is undefined. I'm not entirely sure how to properly set up my factory. Do I need to put a getter and setter ...
1
vote
3answers
46 views
How can I have multiple controller files?
SOLVED
So after viewing your responses and making minor changes to my code, I found a simple typo which prevented me to reach the result I was after. So thank you all to helping with where I was ...
0
votes
1answer
25 views
lazy loaded controller results in error when transitioning to state
Receiving this error...
Error: [ng:areq] Argument 'registerController' is not a function, got undefined
when attempting to transition to a ui-router state...
.state('register', {
url: ...
13
votes
2answers
8k views
Reinitialize an Angular.js controller
if you have a controller to manipulate $scope variables in Angular.js, is there an idiomatic way to:
reset the controller's $scope, and
restart controller initialization?
For complex controllers ...
0
votes
2answers
621 views
Scope Variable Not Being Set Outside of Directive
I am attempting to create an AngularJS directive that sends a file name, from an <input type="file"> element, to a file upload factory. The work is based off the following blog post:
...
0
votes
0answers
23 views
$interval continues to run when I go from one state to other using route
I have a application in which I have to show a page time-out timer progress bar. I am doing it using $interval. But When I go from one state to other the $interval doesn't get cleared and the shows ...
3
votes
2answers
2k views
Breaking change from between AngularJS 1.2 and 1.4?
The following code works in Angular 1.2 but breaks in 1.4 with error Error: [ng:areq] Argument 'MyController' is not a function, got undefined. The code comes from the book "ng-book", and a live ...
0
votes
2answers
34 views
How to access the data after post in Angularjs
My Viewer
<button type="submit" ng:click="sendviewer(vl.viewerid)" ></button>
My Controller
$scope.viewerDetails = [];
var viewerid = [];
$scope.sendviewer = function(viewer){
var ...
1
vote
0answers
25 views
How to validate angular form in controller
How can I validate my angular form in controller? I need to check form and depends on validity show block of text
I've used an example of form from official angularjs website.
And can somebody ...
1
vote
2answers
54 views
Access AngularJs directive variable inside controller
I'm little bit new to Angularjs. What I want is access "$scope.myVar" variable inside 'myController' controller. It would be great help if you can provide a solution.
...
2
votes
3answers
865 views
Controller being called twice in Ionic (AngularJS)
In my angular project the user accepts a EULA then get automatically redirected to their dashboard, however, on this redirect the DashboardController seems to be being called twice, the ...
1
vote
2answers
36 views
capturing the form data inside the Angularjs controller
I am new to Angularjs. I am having the form data which I need to make a post request to the server passing the data. I have done the UI and controller part inside the angularjs but do not know how to ...
2
votes
1answer
40 views
How exactly works the AngularJS application component (module, factory, controller) definition?
I am absolutley new in AngularJS and pretty new in JavaScript and I have the following doubt related to this example showed into a tutorial:
// Creates values or objects on demand
...
0
votes
0answers
19 views
how to attach variable to custom data to state object in ui-router?
I want to attach the the variable which came from controller to data object
.state('403', {
url: '/403',
templateUrl: '403.tmpl.html',
controller: function($scope, $state, APP, Auth) {
...
1
vote
3answers
23 views
Reading data from JSON file in Angularjs using a Promise
I have a factory which provides me a promise when getting a json file :
myapp.factory('topAuthorsFactory', function($http, $q) {
var factory = {
topAuthorsList: false,
getList: ...
204
votes
12answers
145k views
AngularJS : How can I pass variables between controllers?
I have two Angular controllers:
function Ctrl1($scope) {
$scope.prop1 = "First";
}
function Ctrl2($scope) {
$scope.prop2 = "Second";
$scope.both = Ctrl1.prop1 + $scope.prop2; //This is ...
2
votes
1answer
30 views
how to bind the relevant value in case of current status in ui-router?
I have attached data attribute in each .state to identify the user (authenticated or public) as following (one state example)
$stateProvider
.state('admin-panel.public.home', {
url: '/p',
...
1
vote
2answers
33 views
How to attach the controller $scope variable to $state data in ui-router?
In my code I want to attach the $scope.requireLogin value to requireLogin of data. How can I get this in this .state?
.state('403', {
url: '/403',
templateUrl: '403.tmpl.html',
...
4
votes
4answers
368 views
AngularJS: Why not write logic in controller?
Pardon me if this sounds stupid but I have been using AngularJS for aa while now and everywhere I have seen people telling me to wrap my logic in a directive(or service?) instead of my controller and ...
1
vote
1answer
25 views
Call controller method on angular
This is the fist angular app that I try to make ,let's see
var app = angular.module('miApp', []);
app.controller('CochesController', function($scope) {
$scope.coche ={
marca:"Renault",
...
1
vote
0answers
63 views
Upgrading Angular 1.2 to 1.4, controller registers but doesn't run
Solved! It turns out that the project had console.log suppressed, meaning that poor JavaScript was trying to show me errors and failing. Once I got logging back on I was able to see that there ...
1
vote
1answer
23 views
directive not firing on <Enter> keypress
I was following this SO Post on creating an Enter keypress directive.
Here is my JS, in which I simulate the same functionality:
JavaScript
var app = angular.module('myApp', []);
...
1
vote
2answers
35 views
Controller not working in Angular JS
I am new to Angular JS. To see the working of controller, I implemented this simple code where two numbers are taken as an input from the users and their sum is calculated in the controller and the ...
0
votes
2answers
31 views
Trying to display content based on JSON type, no controller w/ angular
I have a JSON file that will contain either an array of objects or a string. I am trying to get this to display based on what JSON type is there.
JSON file,
scenario 1 JSON
"thing":{"important":"a ...
0
votes
2answers
28 views
Is it possible to get access to a controller without declaring it?
I have a bit of a weird situation which requires me to pass my controllers to my directives via a directive scope variable. This works great as long as there are only one controller in use per route, ...
0
votes
1answer
7 views
factory isnt recognized by controller
I have a controller, "ListController", which needs to be populated with server side data.
app.controller("ListController", function(){
var bar = this;
bar.venues = MyFactory.load();
}
and I ...
1
vote
1answer
39 views
AngularJs: Is it possible to pass value to controller or directive from outside?
I'm initialising the controller and directive inside a function that is called somewhere else. So is it possible to send the param value of the function to controller/directive. Here is my code.
var ...
0
votes
1answer
30 views
Pass Laravel Route Variable into AngularJS Controller
What is the best way to pass a Laravel route variable into an AngularJS controller or service?
For example I have a route of domain.com/contacts/87 where 87 is the contact's ID, this route shows the ...
1
vote
2answers
44 views
Directive scope.$watch called after controller function
So I have a controller and directive. I am having trouble understanding why my controller runs after my directive. I have scoured stack trying to find the answer but it seems like most of the answers ...
0
votes
1answer
38 views
How to Pass Scope Variable in ng-click and how to access the Parameter in angularJS Function within Controller
How to Pass Scope Variable in ng-click and how to access the Parameter in angularJS Function within Controller ?
My Source Code is
<!DOCTYPE html>
<html>
<script ...
0
votes
0answers
57 views
$scope.variable is undefined - AngularJS [duplicate]
I have a query rather than a problem.
HTML:
<ion-view view-title="Register" ng-controller="RegisterController">
<ion-content>
<div class="padding">
<label class="item ...
16
votes
5answers
401 views
AngularJS controllers, design pattern for a DRY code
I have created a full example for the purpose of describing this issue. My actual application is even bigger than the presented demo and there are more services and directives operated by every ...
0
votes
2answers
38 views
Angularjs - Argument 'homeController' is not a function, got undefined
I have an ionic application that gives me below mentioned error when navigating `homeController's scope.
Here's my app.js file:
var app = angular.module('app', [
//external modules
'ionic',
...
124
votes
5answers
39k views
Can an AngularJS controller inherit from another controller in the same module?
Within a module, a controller can inherit properties from an outside controller:
var app = angular.module('angularjs-starter', []);
var ParentCtrl = function ($scope, $location) {
};
...
4
votes
2answers
31 views
Controller gets initiated twice
I have a simple controller (logincontroller) which gets initiated twice when loading login.html, however I do not know why that happens.
MyApp.js:
angular.module('PVM', [
'Authentication',
...
0
votes
1answer
42 views
how to get the current view contents only in angularjs controller?
I'm dealing with md-tabs-wrapper it gives the partial view of each category and a single save button as follow
The existing code for it
<md-dialog aria-label="Profile edit" ...
5
votes
2answers
4k views
AngularJS : controller scope won't sync with promise
I've picked up a project and I'm trying to return some data from a service to my controller. I've been at this for about 12 hours, and have tried different methods. They all usually result in this ...
0
votes
0answers
31 views
Angular controller: access scope of parent directive
I have a directive myDirective with a nested controller myCtrl (Yes I know that's not a good design practice and I'll be refactoring it later, but I don't have the time to refactor it right now). In ...
0
votes
1answer
40 views
Setting a two-way bound directive attribute in the HTML with AngularJS
I'm just starting out with AngularJs and have run into an issue that might be the result of not understanding directives / controllers /isolated scope properly. I'm trying to find a way to set a ...
0
votes
1answer
156 views
Error while defining an angularjs controller
I have an view (insight index.html) like that:
<body ng-app="mainApp" ng-controller="MainCtrl">
[...]
<div>{{status}} </div>
</body>
I start the App onDeviceReady:
...
0
votes
2answers
51 views
Function in Controller not being hit
First time asking a q, so if I'm doing something wrong, please let me know so I can fix it as I have tried finding the answer on here, but can not, so any and all help would be greatly appreciated.
...
0
votes
1answer
28 views
Pass object down to the child directive results in unexpected undefined
It's like third day im confused by this, and I'm going crazy already.
The intro
I'm writing an app in which, among others, I'm registering people - creating entry for person with plenty of related ...
31
votes
11answers
49k views
Error: [ng:areq] from angular controller
This is a long shot, but has anyone seen this error before? I am trying to add 'Transporters' using express, angular and mongoDB. I get this error whenever I access a page ruled by the transporters ...
1
vote
2answers
37 views
how to do easily the group of filtering conditions in angularjs?
I have four filtering such as JobType,Experience,DateAdded and Salary i want to do filtering as individual and group. For it i defined a filter as filterType in my controller and added to template ...
0
votes
2answers
39 views
How to share a variable between multiple modules in AngularJS
I'm new to AngularJS and understand the basic principles. However, I'm having a case now where I don't yet know how to get to the solution.
Let me briefly explain you the case. Let's say you have a ...
0
votes
2answers
55 views
AngularJS - $rootScope variable initialization fails
I'm trying to initialize a $rootScope array variable (arrayX) and use it in a $rootScope function in the same controller (controllerA).
The reason i'm using $rootScope instead of $scope for this ...