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
16 views
How can I modify my directive's templateURL based on values within its controller?
I have the following AngularJS directive and its controller.
Instead of entering the HTML right into the directive's template field, I would like to set the templateURL based on values of integers aB ...
0
votes
2answers
27 views
Bug - AngularJS Service with GET JSON file
I am working on a simple sample AngularJS application that reads data from an external JSON data file. I have tried everything, and I cannot find why the application does not work. Any input would be ...
0
votes
0answers
23 views
How to get rid of Uncaught SyntaxError: Unexpected token a in angular js
When i try to run below code i got error:
SyntaxError: Unexpected token a
at Object.parse (native)
at pc (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.min.js:14:219)
at Yb ...
1
vote
1answer
12 views
ngMap directive not displaying the location coordinates taken from service file
I am trying to call location coordinates from service file and display in google map view. But for some reason the data binding is not working, and there are no errors and the controller is calling ...
0
votes
2answers
36 views
AngularJS Call Controller Function from Javascript
In Angular SPA application, you would normally have the following codes in app.js
var app = angular.module('MyApp', ['ngRoute']);
app.config(function ($routeProvider){
$routeProvider.when("/home", ...
0
votes
0answers
26 views
AngularJS sending only the default values of model to the API controller
I am creating a Single Page Application using ASP.NET Web API and AngularJS.
The problem is that when I post data from AngularJS controller to API controller, the object is getting passed but all the ...
0
votes
2answers
16 views
Service function not found in angular app
I added a service to my angular controller, but it says every time there is no function. I really dont know why and hope there is someone who can help me.
Here is my userCtrl.js ...
0
votes
1answer
18 views
AngularJS get the values in a table
I have a table name Post, the function below Posts.query give me all the post and stock them in a variable postsATraiter.
Posts.query({}, function() {
$scope.postsATraiter = $scope.posts;
});
...
0
votes
0answers
15 views
Pass multiple value to a controller through ng-init
I made a controller that retrieve the the content of a HTTP get and a directive that will display the result, I use them like that :
<div ng-controller="averageAlertController"
...
0
votes
1answer
24 views
Some prbm in angularjs lib default value is not working in select if(value and name) same? [duplicate]
Here I create sample for select in angular... Which is working fine.. I tried to set default value for select if I set this $scope.selectedValue = "SureshRaina";
working fine... but if I set this ...
0
votes
1answer
25 views
Angular - reusing code (service or controller)
I'm using Angular to develop commenting functionality for a web app.
Currently there are two sections in the application were a user can comment:
Category
Product
About 90% of the commenting ...
0
votes
2answers
21 views
Angular template not displaying the service file data
The template file is not displaying the data from the service file, can someone please check the code and correct me. Thank you.
Also I checked if data is passed by controller, which is happening. ...
209
votes
12answers
150k 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 ...
0
votes
1answer
24 views
AngularJS - Using Model in Controller causing Model to update
I have an Angular application where in I'm pulling from a model some data which is saved on the load of the app. For simplicity sake, I've explicitly defined the data which is being pulled.
The issue ...
0
votes
1answer
24 views
How to get i18n from different location with good performance?
Link for sample
Sample File
Here I created some sample application for locale..In that application
I created only few Json file in same location...one for English another one for ...
4
votes
1answer
35 views
How to achieve base class and derived class concept in angularjs?
In angular js how to achieve base class and derived class concept?. My requirement In base controller I need to create some method and derived controller i need to override that method.. can anyone ...
-1
votes
1answer
50 views
Linking one controller to another to call service on ng-click
I have two templates with respective controllers and service files. One template's(fleetListTemplate) controller(fleetListController) loads data from its service file(fleetService) and displays in ...
0
votes
0answers
29 views
What's the right way to conditionally display forms in AngularJS
I am working on a little project that supports search filters. I have a default select dropdown from which a user can select e.g. Product Name, Status and Date. These options determine which type of ...
-1
votes
2answers
14 views
Error: [ng:areq] Argument 'ext-modules/fleet/jsFleetController.js' is not a function, got undefined
am getting "Error: [ng:areq] Argument 'ext-modules/fleet/jsFleetController.js' is not a function, got undefined" this error message when ever I load the template file.
The following are the code, ...
9
votes
2answers
21k views
AngularJS: $scope.array.push() does not update the view, even with $apply
I'm trying to learn AngularJS and there is this thing that I don't understand, which seems like all the internet solved by using $scope.$apply, but I already use it and it does nothing.
Basically, I ...
0
votes
0answers
21 views
Access $controlProvider after bootstrap from third-party code
I develop some library/plugin which is loaded after AngularJS application is bootstrapped and intended to make some changes in this app. So, I cannot register my own controllers or directives because ...
0
votes
1answer
27 views
Calling service.js file from controller
I have a service file which needs to be called from the controller. Can someone please tell the code which should go in the controller to get this service file. Thank you.
This is my service file ...
2
votes
1answer
17 views
TypeError: Cannot read property 'get' of undefined Angularjs
Im try to use Oboe.Js and Angular.Js together
Here is my sample code which is working correctly..
angular.module('myApp', ['ng-oboe'])
.config(function (oboeProvider) {
/* If we were ...
2
votes
1answer
28 views
AngularJS constants undefined is not an object
new to Angular and I'm trying to inject constants from a separate file. It seems to work with the DI, but when I try to use it, I get an error: Error: undefined is not an object (evaluating ...
32
votes
12answers
51k 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 ...
4
votes
1answer
4k views
TypeError: (intermediate value)(intermediate value).success is not a function (angular)
I have difficulties understanding this error... I dont quite understand why its not a function....
angular.module('mkApp').factory('mkService', function ($http, $log) {
function ...
1
vote
1answer
31 views
How to test a directive which uses ngModel on same element
I have a directive which requires ngModel. In its link function it calls $setViewValue on the ngModel controller. I want to test that $setViewValue is being called under the right conditions, but I ...
0
votes
2answers
46 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>
...
-1
votes
1answer
19 views
TypeError: value is undefined angularjs
I have a controller
.controller('ArticlesCtrl', function($scope) {
$scope.sum = function(value) {
return value.reduce(function(total, article) {
return total + article.price;
}, 0); ...
2
votes
2answers
89 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 ...
107
votes
8answers
56k 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
49 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
12 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
64 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
30 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: ...
16
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
629 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
27 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
36 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
34 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
70 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
992 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
40 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
42 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
23 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
33 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: ...
2
votes
1answer
34 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
37 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
449 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 ...