FAQ Database Discussion Community


angular.js - simplest way to handle click inside controller

javascript,jquery,html,angularjs
is there any better way of handling clicks inside a controller than this? <div ng-controller="SomeController> <a href="/#!/something" ng-click="doTheSame()">link1</a> <a href="/#!/something" ng-click="doTheSame()">link2</a> <a href="/#!/something" ng-click="doTheSame()">link3</a> .. <a href="/#!/something" ng-click="doTheSame()">link99</a> </div> in jQuery I would do something like: $('div > a').on('click', function() { // do some stuff }); ...

ng-repeat not working in md-chip

angularjs,angular-material
Why is md-chip not supporting ng-repeat? <md-chips> <md-chip data-ng-repeat="category in book.categories"> {{category.name}} </md-chip> </md-chips> ...

function is undefined if no module is declared in Angular

angularjs
I am new in Angular and I am studying controllers. In my code I setup a simple controller access but when I tried to run in my browser I encountered a series of error messages that looks like this: "Error: [ng:areq] Argument 'personController' is not a function, got undefined In...

$scope variable does not update within $interval function

javascript,angularjs,angularjs-scope
I am using $interval for my custom stopwatch. Within the $interval function I have a variable $scope.inputValue which is binded to a range. The problem is that after each iteration of $interval (every 500ms), the most recent $scope.inputValue is not taken into account, but only the value at the initialization...

Pass scope to element.after()

angularjs,angularjs-directive
The below is called in my HTML: <input data-autocomplete> There is a parsing error (basic HTML error) because when data-autocomplete is ran, it calls another directive inside its HTML: data-autocomplete-results. When this is run/compiled, it creates a div inside of the <input> element and because that is bad HTML it...

Programmatically enable GPS of device when application opens in cordova

angularjs,cordova,ionic,cordova-plugins
I have been working on cordova ionic app with angularJS frontend. Here when this app is getting launch the device should check for the status of the GPS whether it is on or not and if it is not on then make it on automatically. I didn't found any cordova...

AngularJS, Animate on change: directive $watch not called

javascript,angularjs,angularjs-directive
I'm creating a live websocket application which requires grabbing the users attention upon change of a value. The following directive is used in multiple places on the same page: <span class="badge" animate-on-change animate-class="highlightWarning" animate-watch="totalAnswers">{{totalAnswers}}</span> and <div animate-on-change animate-class="colorWarning" animate-watch="rq.answer" ng-switch="question.type" ng-repeat="rq in recentResponse.answers" ng-if="rq.question == question.id"> Now, rq.answer rarely changes,...

AngularJS - $scope undefined within same controller

angularjs,angularjs-scope
I have a controller where I am trying to store information in $scope.weather and then use it's contents to pass to a function. When I log the result of $scope.weather[0].latitude when I use it one function but when I call it another function within the same controller the result is...

AngularJS: Adding ng-click within element.append

angularjs,directive
Within my directive I have the following code, which will be used to continually append to an html element. //Establishes the type of question and therefore what should be displayed app.directive('questionType', function ($http, $compile) { return { restrict: 'A', link: function (scope, element, attr, model) { switch (scope.Question.inputType) { case...

Angularjs $watchCollection on $rootScope not triggered when values updated from directive

javascript,angularjs,events,angularjs-directive,angularjs-watch
I'm running into a bit of an issue solving a problem with some Angularjs functionality I'm working on. The basic idea is that I have a system where certain criteria must be met before the user is allowed to advance to the next section of the app. One example of...

What is the difference between these two angularjs controller definition

angularjs,angularjs-controller
I don't understand the difference between these two types of angularjs controller definition, i have tried following codes and found both working myApp.controller('GreetingController', ['$scope', function($scope) { $scope.greeting = 'Hola!'; }]); myApp.controller('GreetingController', function($scope) { $scope.greeting = 'Hola!'; }); ...

Angular Js Drag and Drop - Passing $index to Directive

javascript,angularjs,drag-and-drop
I have been successful in implementing the Drag and Drop feature in Angular JS. The basic idea is like Match the City with the Countries. I am able to drag the city and drop in into the Country box. But, the dropped item gets reflected in all the country box....

ng-Repeat returning undefined within $scope.$watchCollection

angularjs,ng-repeat,ng-init
When I console.log(result) on line 5, it returns just fine. The console.log($scope.notes) on line 11 returns undefined. Any ideas? Here is my controller: $scope.$watchCollection = (['parent_id', 'parent_type'], function(){ $scope.loadNotes = function(){ $http.get('/api/notes/' + $scope.parent_id + "/" + $scope.parent_type).success(function(result){ console.log(result); $scope.notes = result; return result; }); } $scope.notes = $scope.loadNotes(); console.log($scope.notes);...

Can't get angular.js to loop through array and post to html

angularjs,ng-repeat
Edit: changed ng-controller to ng-app in body tag, was typo I'm new to angular and im trying to use ng-repeat to post all items in the products[] to html but the {{expressions}} come out as text rather than computing. I don't have my laptop so I'm testing all this on...

I want to add an element inside an array, but not getting how to do this using angular

angularjs
I want to add another name under subChild in Object. Do we have any method for doing this. In subdomain I have another name. Which I need to add under subchild. I tried childBD[i].subChild.push(busDomain); I also tried childBD[i].subChild.concat(busDomain); but it is throwing an error TypeError: childBD[i].subChild.push is not a...

validation of AngularJS direcrives

angularjs,html5,html-validation
I read on W3C School that to make a valid HTML page I have to add data before each angular directive in HTML file (e.g.: <p>The name is <span data-ng-bind="firstName"></span></p> or <div data-ng-app="" data-ng-init="firstName='John'"> Ok that's fine. I have two questions: Should this prefix be used only for ng- directives?...

ngOption default selected option

angularjs,angular-ngmodel,angular-services,angularjs-ng-options
How to have a default option in select box...I tried several options and do not get it I tried creating a scope on my contralador with the value of the object that comes from json: Like this: $scope.productSelect = $scope.item[0]; this my code: html: <select id="variant" class="form-control variant-select" ng-model="productSelect" ng-options="product...

AngularJS - binding/linking two directives together

javascript,angularjs,angularjs-directive
What is the preferred way to link/bind two directives together? I have a controller with two directives, first directive is a select element, after selecting option, second directive should process selected item value. App code: var app = angular.module('plunker', []); app.controller('MainCtrl', function() { var sharedData = { selectedId: '' };...

recursive function with an array as input

javascript,angularjs
I am trying to create a function that gets chest exercises from an array called chest. This function needs to be able to pick several exercises at random, which I have done using a random pointer. To stop duplicate exercises I compare the chest exercise picked (i.e chest[pointer]) and compare...

Uncommon “10 $digest iterations reached” case

angularjs
Abstract Hi, I think everyone has faced a problem entitled “10 $digest iterations reached”. Typically it is caused by recursively changing angular expression that never stop from changing or when watched expression generates new instance on each digest cycle. My problem is that I don't have the above kind of...

Passing argument to a factory for a service

javascript,angularjs
I have this HTML: <div class='container-fluid' ng-controller="TypeaheadCtrl"> <p></p> <b>Selected User</b> Enter a name: <input type="text" ng-model="selected" typeahead="user as (user.first + ' ' + user.last) for user in users | filter:$viewValue" /> </div> this controller: app.controller('TypeaheadCtrl', ['$scope', 'getUser',function($scope, getUser) { $scope.selected = ""; getUser.success(function(data) { $scope.users = data; }); }]); and...

AngularJS dynamically call function

javascript,angularjs
at this point, I'm new to AngularJS. This works: scope.$apply(scope.hideTooltip()); But calling the function dynamically does not work: scope.$apply( scope.$eval(attrs.ngEnter, {'event': event}) ); HTML: <input type="text" ng-model="value" ng-enter="hideToolTip()" /> The enitre directive: app.directive('ngEnter', function() { return function(scope, element, attrs) { console.log(scope.hideTooltip()); element.bind("keydown keypress", function(event) { if(event.which === 13) { console.log(attrs.ngEnter);...

navbar disappears but no dropdown

angularjs,bootstrap
So been trying to set up a navbar that collapses to a drop down when the size is under a certain number of pixels. So far I have managed to make the normal menu disappear when it goes under a certain size, but once I make the window smaller and...

HTML elements in Angular bindings expression

html,angularjs
Is that possible to insert HTML elements in an Angular expression ? Let's take a few example. I would like to do something like this: <table> <tr ng-repeat="employee in employees"> <td>{{employee.firstname ? employee.firstname : '<p style="color:red">No name</p>'}}</td> <td>{{employee.job}}</td> </tr> </table> In our controller, we have: $scope.employees = [{firstname:'Bob', job:'Developer'}, {firstname:'Paul',...

Getting generic anchor text on click with angularJS/jQuery returns empty string

jquery,angularjs
I have an anchor generated from a JSON database query result. The anchor represents the title of an article (I have no idea how many articles there will be). I want to be able to get the anchor text (the article title), upon clicking the anchor in order to use...

AngularJS use a directive inside a ng-repeat

angularjs,angular-directive
I have a directive which I am unable to use inside an ng-repeat block. Here is my directive: ap.directive('pastDate', function() { return { require: 'ngModel', link: function (scope, element, attrs, ctrl) { ctrl.$validators.pastDate = function(modelValue) { // 'pastDate' is the name of your custom validator ... var today = new...

calling one controller from another controller

angularjs
I have 2 controllers and I am calling the second controller from the function of first controller $scope.open = function () { var modal = $modal.open({ templateUrl: 'views/view1.html', controller: 'controller2', // other parameters }); /* some code */ } Both the controllers are in the same folder. There are similar...

Angular directive not applied on change of the value

javascript,angularjs,angularjs-directive
I have a directive like testApp.directive('changeValue', function(){ alert("coming"); return { restrict: 'E', link: function (scope, element, attrs) { element.text(attrs.val); }, replace: true }; }); and I have my views as follows <change-value val="{{test.val}}"/> When I refresh my page, I could see the values and I get the alerts. But when...

Merge and sum values and put them in an array

javascript,arrays,angularjs,foreach
I'm retrieving values from an external source and apply a foreach loop to the results, with the code below. angular.forEach(data, function(value, key) { if (value.start_date > firstdayOfWeek && value.start_date < lastdayOfWeek) { console.log(value.firstname + ' - ' + value.distance); } else { //do nothing } }); The result is console...

ReferenceError: Invalid left-hand side in assignment using OR

jquery,angularjs
data['username'] = $("#username").val() || validated = false; if(validated){ //save to db } I want to write shorter code, to assign validated to false if username is empty. But why it doesn't work with above code?...

success and error function in the controller for a service

javascript,angularjs,angularjs-service,angularjs-http,angularjs-promise
I have the following code in a service and I am calling fetchData function from the controller. Service app.service("geturl", function($http) { urllist = []; geturl.fetchData = function() { var data = []; for (i = 0; i < urllist.length; i++) { (function(index) { return $http.get(geturl.urllist[index], { timeout: 8000 }) .then(function(response)...

Iframe does not show scrollbar

html,css,angularjs,iframe,ionic
Can't seem to make the iframe appear with a scroll-bar. Go to https://billiving-qa.azurewebsites.net/accountant email: [email protected] pass: 111111 Reload the list with F5, then click new invoice on the right side. The content is lengthy but doesn't show the scroll-bar. My css uses the following: .frm { position: fixed; width: 100%;...

Angular controller error: 'Controller is not a function, got undefined'

javascript,angularjs,angularjs-controller
I am getting the following error in my angular application: Error: [ng:areq] Argument 'HomeController' is not a function, got undefined. My JS and HTML are below. This is actually a part of an ionic/cordova project, but here is a simplified jsfiddle in which I encounter the same problem. My JS:...

Using indexOf() to search array inside ng-repeat

javascript,angularjs,indexof
I'm try to search an array of id's [1, 2, 3] with indexOf() inside an ng-repeat loop, but probably because of a wrong data type, it doesn't work. <li ng-repeat="member in message.members"> Member ID: {{ member.id }} <span ng-if="message.read_by.indexOf(member.id) > -1">Read</span> </li> The array message.read_by = [1, 2, 3] and...

Cannot read property 'then' of undefined - AngularJS

angularjs,restangular
I want to include Asp.Net Identity into my app. But when I want to register a new user, I get an error on javascript side: Cannot read property 'then' of undefined. This is the code in my Controller: When I click the button to register the user, I get in...

Animate removal of list items with css

css,angularjs,css3,animation,css-animations
I have made the animation of a showing/hiding a list of messages. See this plunk. But how can I adapt it to also make an animation when a message is removed from the list? My css: .messages-active.messages { max-height: 50px; } .messages { -webkit-transition: max-height 1s; -moz-transition: max-height 1s; -ms-transition:...

UI-Router : Prevent access to parent state

angularjs,angular-ui-router,state
I am moving to UI-Router as my App router. I want to have nested state as below: $stateProvider .state('app', { url: '/app', template: ' <div ui-view></div>', authenticate: true }) .state('app.state1', { url: '/state1', templateUrl: 'app/state1.html', controller: 'State1Ctrl', controllerAs: 'state1', authenticate: true }) .state('app.state2', { url: '/state2', templateUrl: 'app/state2.html', controller: 'State2Ctrl',...

AngularJS factory dependencies

javascript,html,angularjs,mongodb
I'm using AngularJS to extract information stored in mongodb. I'm trying to use a factory to retrieve that information using $http . I read so much information about how to do it, and no one works for me. Also I'm using node + express, the routes works fine. The problem...

Value lookup on the fly in angular

angularjs
Got two sets of data. The first one is postits and the otherone is userlist. Each object in postits contains a set of values about a document, one of them being the owner, which is set to the internal id. The second set (userlist) contains the id of users and...

How to use a service with Http request in Angular JS

javascript,angularjs
I'm using AngularJS to build my web application, I've been always using controllers to make HTTP request, which makes things easier and clear for me. But for a better code structure, and better execution for my application, I wanted to use services instead of controllers to use the web service....

text formatting with AngularJS

angularjs
I have a mysql database that stores a text value (a body of an article), that I want to display on my page. I would like to store and then display some text formatting but don't know how to do it with angular. I use the php PDO echo json_encode...

String comparison in AngularJS

javascript,json,angularjs,ionic-framework,string-comparison
I'm trying to compare two strings in AngularJS, and I've seen examples online. As I understand it, you can use angular.equals(str1, str2), you can use ===, you can use == if you're sure that both are strings... I've tried all three, but I don't get the result. Something must be...

AngularJS & Bootstrap Modal - loading template outside controller

angularjs,twitter-bootstrap,angular-bootstrap
I have a dialog which is being used in 3 scenarios within the same page. I have created a controller similar to the below: var modalInstance = $modal.open({ templateUrl: 'myModalContent.html', controller: 'ModalInstanceCtrl', size: size, resolve: { items: function () { return $scope.items; } } }); <script type="text/ng-template" id="myModalContent.html"> <div class="modal-header">...

Angular submit not called when required fields not filled

javascript,angularjs,forms
I'm creating a form in Angular with Ionic. I don't want a red error class to be displayed unless a user has submitted the form. As such, my code looks like this: <form ng-submit="submit()" name="form"> <ion-radio ng-repeat="item in items" ng-model="data.type" name="type" ng-value="item.value" ng-class="{'error' : form.type.$invalid && formSubmitted }" </form> And...

angular filter in order by letter

javascript,angularjs,angular-filters
I am pretty new to angular. I am trying to add a filter parameter to my controller that will filter a search by every letter in a word, in order of letter. So imagine my data contained the following words: horses, oranges, terminator, Motorola, floral, orthopedic. When I searched for...

How do I add a class on ng-click from layout?

angularjs
Here is the page layout: <li class="dropdown"> <ul class="submenu"> <li ng-click="SetActiveMenuForPersonalInfo();"> <a href="../Account/#/PersonalInfo">@Translate("MY_ACCOUNT")<a> </li> </ul> </li> When a user clicks on my account, they get this: http://plnkr.co/edit/gJko3umteXXEye7o9StR?p=preview This is the function in the controller: $scope.SetActiveMenuForPersonalInfo = function () { $scope.activeMenu = 'Settings'; $scope.activeLink = "PersonalInfo"; console.log("Active menu:...

$rootScope is undefined in $urlRouterProvider.otherwise

angularjs,angular-ui-router
i am getting $rootScope is undefined when using it from inside $urlRouterProvider.otherwise. My objective is to checkout if user is currently loggedin or not, during login i set the variable on rootScope. Interestingly if i make the $rootScope the first argument, then i start getting error for $injector. $urlRouterProvider.otherwise(function ($injector,...

Add multiple rows from same model AngularJS

angularjs,node.js
Considering I have a list of users to add into my system and I don't want to do it one-by-one process. Then I want to see one user form (name, email, password fields) and by the end of the row i see the "add another row" button. By clicking on...

Display unlisted value in select with ng-options

angularjs
I have a <select> element populated with the acceptable values via ng-options and bound to a model with ng-model. It is possible that the model is set to a value that is not acceptable. (It used to be acceptable but no longer is.) In this case AngularJS renders the <select>...

Create angular page in Django to consume data from JSON

angularjs,django,django-templates
In an angular controller I have a list of items: app.controller('MainController', ['$scope', function($scope) { $scope.items = [ {"foo":"bar 1"}, {"foo":"bar 2"}, {"foo":"bar n"} ] }]); The following html page, based on angular, displays a list of item: <!DOCTYPE html> <html> <head> <title>list</title> <script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> </head> <body data-ng-app="myApp"> <div data-ng-controller="MainController">...

$http.get returns actual php script instead of running it (yeoman, grunt)

php,angularjs,pdo,gruntjs
I'm building a "simple" AngularJS app with an articles newsfeed. My articles are stored in a mysql database, and I extract them using php PDO. I used to do this using AJAX with a simple LAMP configuration (php5, mysql, apache2), and everything worked as intended. Now I'm trying to rebuild...

How can this be undefined in the constructor of an Angular config class?

angularjs,constructor,typescript,undefined,this
I've found some examples online, where people create TypeScript config classes and pass them on to Angular. When I've tried it, I got the weird exception, that this was undefined. A closer look to the other implementations revealed, they only use the constructor, so, are those examples actually inherently wrong...

Angular: On button click to invoke controller

angularjs
I am new to Angular and have the following behaviour working at present: dropdown-section contains a button dropdown listing all competitions by name schedule-section contains content loaded from my controller that displays a full schedule of game information I now need to implement the following behaviour: user selects a list...

KendoUI Popover $compile issue

angularjs,angularjs-directive,kendo-ui,angularjs-compile,kendo-tooltip
I have directive which is a wrapper around KendoUI kendo-tooltip and I'm instantiating it like this: <div my-directive-popover="options"> </div> Inside my code I replace my-directive-popover with kendo-tooltip like this: $element.attr( 'kendo-tooltip', popoverName ); At the end of pre compile function I have to of course compile this so it's recognized...

Angular $http and Fusion Tables in IE9

javascript,angularjs,internet-explorer-9,google-fusion-tables
I am trying a simple get request to a google fusion table in my angular controller. $http.get(url) .success(function(data) { //Do stuff with data }) This works in firefox, chrome, safari and IE10+ however in IE9 (Which I am requried to support) the request fails to even send and the console...

How push object onto array of array in Angularjs

javascript,arrays,angularjs
i want to create a object such as this $scope.allBooks = { books:[ { name:"", id:"" } { name:"", id:"" } // can be add another object ] books:[ { name:"", id:"" } { name:"", id:"" } ] } in fact be able to add more object to books and...

Security features in angularjs

angularjs
Hi i would like to know about the security features of angular js.I have read that angular provide built in protection from basic security holes. It Prevents cross-side-scripting attacks. Prevents HTML injection attacks. Prevent XSRF protection for server side communication. what are the best practice to make a secured angular...

Getting CROS Error even after adding header in node.js for Angular js

javascript,angularjs,node.js
I am trying to consume REST API from NODE JS for Angular js,even after adding cors header in my server code I am getting error XMLHttpRequest cannot load http://127.0.0.1:8085/issues. Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers. I am new to both Angular JS and Node JS. Node JS...

Angular ng-repeat cache (avoid re-rendering on state change)

javascript,angularjs,performance,caching,angularjs-ng-repeat
We have huge rendering spikes with ng-repeat in Angular application. Main page shows a huge list of cover images ("::" and "track by" are in place). On first load it works acceptable. But if user changes the state (we use UI-Router) and goes back to the home page afterwards then...

jquery append() is creating two div elements

javascript,jquery,json,angularjs,jquery-ui
I am adding div elements dynamically to the DOM using jquery append(). I have made a controller that takes json data using $http.get() and calls a function create_mission to add the divs to DOM. I have to create a div for every object of the json, so i have done...

REST API with token based authentication

angularjs,codeigniter,api,rest,token
I want to develop a web site with AngularJS. On the backend side I will use Codeigniter REST framework. I have some security issues and I don't want to start developing without fixing them on my mind. I don't want to use something like api key because it will be...

Angular error i dont understand?

angularjs
I am trying to build the Menu that is here: http://jsfiddle.net/1vgcs4we/ However when i implement it into my project i get the following error message: Syntax Error: Token 'node.click' is unexpected, expecting [:] at column 3 of the expression [{{node.click}}] starting at [node.click}}]. The result i get is i can...

XSS in angularjs app and web api 2

angularjs,xss,asp.net-web-api2,antixsslibrary
I have a web application. I am using Angularjs and Web Api2. I have a simple form where user can insert some free text that will be send via email to other people. The text is also saved on db and later can be shown in a web site page....

Can't save json data to variable (or cache) with angularjs $http.get

json,angularjs,web-services,rest
I have weird angularjs problem. I'm trying to fetch data from Rest Webservice. It works fine, but I can't save json data to object. My code looks like: services.service('customerService', [ '$http', '$cacheFactory', function($http, $cacheFactory) { var cache = $cacheFactory('dataCache'); var result = cache.get('user'); this.getById = function(id){ $http.get(urlList.getCustomer + id).success(function(data, status,...

How to access HTML variable in Java-script in angularJS

javascript,angularjs
I am filling a select list in angularJS. This is the code. <select class="form-control" ng-model="NewProduct.category" ng-options="category.id as category.name for category in Categories | orderBy:['name']" ng-change="update(NewProduct.category)" required></select> On change it calls update function; which print categoryID. $scope.update = function (value) { alert ($scope.NewProduct.category); }; But i want to access both categoryID...

How do I update a view after ng-submit calls a factory function?

javascript,angularjs
$scope.temp and $scope.description don't have values until ng-submit calls $scope.getWeather. I can log the values after submission, but can't update the view to display them. $scope.test is demonstrating that my view will only display "This is a DEFAULT value" and not update to "This is the NEW value" when $scope.getWeather...

AngularJS line break at points after a maximum length was reached

javascript,angularjs
I'm using ng-repeat to fill a table. Some elements have a pretty long length, and I'm looking for a way to cut the content into multiple lines, if a specific length is reached. During research I found Angulars limitTo, but it does not exactly look like I was looking for....

Error: [$injector:unpr] Unknown provider: RestangularProvider <- Restangular <- ctrlAG

javascript,angularjs,restangular
I have one app: app.js: angular.module('AngApp', [ 'angularGrid' ]); My own restangular service.js: var app = angular.module('AngApp'); app.factory('restService', ['Restangular', function (Restangular) { // make use of Restangular } ]); and controller.js: var app = angular.module('AngApp'); app.controller('ctrlAG', ['$scope', '$http', '$log', '$mdDialog', 'Restangular',function ($scope,$http, $log, $mdDialog, Restangular) { // make use of...

Updating View in Angular js on ajax success callback

ajax,angularjs
I am working on a project where I am getting list of the offers from a service. Each offer is Active or Inactive. I am displying only Active offers on a view on tabular format by giving ajax call and using ng-repeat. When I click on the link Inactivate Offer...

Angular-strap data-trigger='focus' not working

javascript,html,angularjs,angular-strap
the data-trigger focus is not working for me ... <span data-content='foo' data-html='true' data-placement='top' data-container='body' data-trigger='focus' bs-popover> Nothing is actually happening when I am clicking on this element. If I remove data-trigger='focus' and set it to hover or click, it does work. I am using angularjs. 1.2.18 and angular-strap : 2.2.4...

Is there a before() function in Protractor?

angularjs,node.js,automated-tests,protractor,hierarchy
I am aware there is a beforeEach() function which I am currently using. However, I would like to be able to run a before function for all my parent level 'describes' and not the 'it' functions within them. For example my test looks like this (with an x in front...

Check if expression in directive is defined?

angularjs
In my directive I use expression: return { restrict: 'E', scope: { func: "&?" }, controller: 'directiveCtrl', controllerAs: 'vm', bindToController: true } function directiveCtrl() { var vm = this; vm.isFunc = angular.isDefined(vm.func) || false; } How to check if func is defined? Now it's always defined:/ <my-directive></my-directive> <my-directive func='myFunc()'></my-directive> ...

AngularFire pushing to array doesn't work

javascript,arrays,angularjs,firebase,angularfire
I'm developing a contact book application that can have groups with members in them. A member has a name, title, and email but that is not important. I have following controller that has an array of all groups, and an index of which group I'm currently dealing with. Also, there...

Using ng-click to toggle between two functions

javascript,angularjs,angular-ui,angular-ui-bootstrap
I am using the datepicker from bootstrap-UI for angular. I would like to toggle between two functions. now() and clear(). Is this possible inside Angular's ng-click? http://plnkr.co/edit/aMcKwXOSQwgnGwfNN9yI?p=preview The toggle has the ng-click="today()" I would like to add clear() to it, thanks. Controller Code: $scope.today = function() { $scope.dt = new...

How to preserve an object initial data?

angularjs
I am facing some weird behavior with AngularJS in preserving a variable data which got binded to a from using scope, let me explain my scenario. I have a form whose field values are initially served form controller through a scope variable, I need to compare the updated values with...

configuration of karma/jasmine to test angularjs throws: No provider for “framework:jasmine”!

angularjs,unit-testing,karma-jasmine
Hello I'm trying to implement unit-tests for angularjs with karma and jasmine. I followed therefore this tutorial: http://tech.pro/tutorial/1473/getting-started-with-angularjs-unit-testing On the point Running Your First Test I get sucked because of an error: No provider for "framework:jasmine"! I googled for it and tried the suggested things like installing karma-jasmine and karma-chrome-launcher...

Passing params to an angular service from a controller?

javascript,angularjs,service,controller,params
I'm an angular newby. I'm hoping to pass params to a service that fetches data form a server depending on those params. for example, if I want to pass a book name string and then use it in the service to concatenate with the request url. The documentation does not...

Socket.IO message doesn't update Angular variable

javascript,angularjs,node.js,sockets
I have a socket.io client-server setup with AngularJS running on the client. // Server.js var io = require('socket.io')(server); io.on('connection', function (socket) { socket.on('message', function (msg) { //console.log(msg); console.log(msg); io.emit('message', msg); }); }); As observed, it essentially emits a message events with the data stored in the variable msg. And then...

Toggle Class to select offer with angular

javascript,angularjs
I try to make something and I try to figure out. I want to add a class only to the clicked div. If div number 1 is clicked and I click on div number 2, the class is removed from div1 and added to div2. Hope you understand. here 's...

How to disable the form submit when input fields are incorrect in angularjs

angularjs
I have a form where I am checking for incorrect input with ng-pattern and showing error message on incorrect entry. I want the form submit to be disabled when user tries to submit the form with incorrect values with out using ng-disabled option because required option of html is checking...

Change placeholder value depending on locale - angularJS

angularjs,localization
Does angular localization provide this: Can the placeholder value change depending on the locale? I have an input control with placeholder="mm/dd/yyyy". It should change to placeholder="TT/MM/JJJJ" for German. Should we write a filter for this? or Angular locale provides it? Thanks in advance. ...

Save to 3 firebase locations with a slow internet connection

javascript,angularjs,firebase,latency
Sometimes I'm having issues with firebase when the user is on a slow mobile connection. When the user saves an entry to firebase I actually have to write to 3 different locations. Sometimes, the first one works, but if the connection is slow the 2nd and 3rd may fail. This...

Calling AngularJS function from a remote page loaded by Bootstrap modal

javascript,angularjs,twitter-bootstrap
I use Bootstrap 3 modal component to load a remote form, in which I define an Angular controller and several functions. But the browser said "Tried to Load Angular More Than Once". Main page: (omitted: ng-app="manageAppCollections", ng-controller="manageAppController") <button type="button" class="btn btn-success" ng-href="./appConfForm" data-toggle="modal" data-target="#saveModal">Add an App</button> <div id="saveModal" class="modal inmodal...

how to align column to the right?

angularjs,css3,twitter-bootstrap-3
I am getting my head around twitter bootstrap 3 and specifically the column setup. I got a 2 columns on the same line: <!--datetime row--> <div> <div class="col-md-6 form-group"> <label for="">Title:</label> <div class="dropdown"> <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true"> Dropdown <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1"> <li...

Pre-Select of an option in a select not working

angularjs
I use the following select. Currently, I get empty options in my select on start. To avoid these empty options in angularJS, I want to preselect the first option in the select. But It do not work. I get an 'Cannot read property 'conditions' of undefined'. Thank you for your...

Can rspec be used to feature test an integrated rails-angular app?

ruby-on-rails,angularjs,rspec,capybara
I have a very basic, integrated rails-angular app. It just renders a link, which uses data from a get request to rails: 'use strict'; angular.module('angularRspec.controllers') .controller('FightersController', function($scope, $http){ console.log("FightersController is loaded..."); $scope.fighters = []; $http.get('./fighters.json'). success(function(data, status){ $scope.fighters = data; console.log(status); console.log(data); }). error(function(data, status, headers, config) { console.log(status); console.log(headers);...

How to add class on ng-click?

angularjs
I have this: http://plnkr.co/edit/gJko3umteXXEye7o9StR?p=preview How can i add class "active-link" on: @Translate("PERSONAL_INFORMATION") @Translate("NOTIFICATIONS") @Translate("CHANGE_PASSWORD") @Translate("GAME_SETTINGS") ...

Ionic tabs : child view not showing

angularjs,angular-ui-router,ionic-framework,angular-ui,ionic
I changed the navigation of my app from side menu to bottom tabs. (tabs). It is working for the parent pages but not showing anything for the children pages. I followed the code given by the starter app and also from the doc. So here what i did : tabs.html...

Provider dependancy not working in Config AngularJS

angularjs,config
My code is given below. The below code shows dependancy error when executes following code. Any help would be great. Cookies dependancies also required... Error is Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.3.15/$injector/modulerr?p0=achieverpayroll&p1…A%2F%2Flocalhost%3A8080%2Fachieverpayroll%2Fjs%2Fangular.min.js%3A17%3A381) Code app.js (function(){ var app=angular.module('achieverpayroll',['ngRoute']); app.provider('loginChek',function(){ this.logFn=function(){ console.log('test'); }; });...

Improve slow angular directive

javascript,angularjs,angularjs-directive
I have a page that renders table view or div/blocks view depending on window width. But the swop between views happens very slow. Maybe I am not doing things in the best way? I basically have 2 scope variables(block and table, set to true or false) defined in the controller....

How to define style to layout-margin flex variants, using Angular Material

css,angularjs,angular-material
I want to have different margins for flex and flex-sm tags: <div layout="row" layout-margin layout-wrap> <div flex="30" flex-sm="100" ng-repeat="occasion in resultObject.occasionTypes[typeIndex].occasions"> ------------ </div> </div> I tried to use something like: [layout-margin] > [flex] { margin: 3px; } [layout-margin] > [flex-sm] { margin: 0px; } But it doesn't work. Is there...

remove char from string with angular

javascript,angularjs
I'm trying to remove a period '.' from a value that comes from a feed, however I don't really want to do this in my app.js, rather in my view. So if I do the following: value: {{item.v_value}} I get 3.5, I'd simply like to strip out and render out...

Compare two arrays to get count of properties

javascript,angularjs
I have two arrays that I would like to compare and provide a count of the items in the master list. The master list might look like this: { name: 'Jon', age: 34 }, { name: 'Steve', age: 33 }, { name: 'Mark', age: 34 }, { name: 'Jon', age:...

Angular material - issues with tooltip and flex

angularjs,angular-material
The issue is that my tooltip is shown on the bottom left part of my button when I hover on the botton for the first time. Then it seems it fixes its position and works as expected. This happens in all desktop browsers. I am using v0.9.8. I have used...

Is there a way to fire an event every time an ajax call in made in AngularJS?

javascript,ajax,angularjs,express
What I'm trying to do is every time a call to the backend is made, I want a spinner to load up with a dark overlay. I know I can do this by simply running the spinner before the call is made, but I'm working with multiple developers and I...

How to select multiple selected value from select option

angularjs,model-view-controller,ionic-framework,ionic
My controller code looks like $scope.items = [{ heading: 'Sports', types: [{ name: 'Football', }, { name: 'Persie', }, { name: 'Ronaldo', }, { name: 'Messy', }], id: '1' }, { heading: 'Cricket', types: [{ name: 'Tendulkar', }, { name: 'Lara', }, { name: 'Ponting', }], id: '2' }]; My...

how to call the application titles and other static messages from a service?

angularjs
here is the code i have tried so far angular.module('app') .factory('PostMeetUpService', function () { var myMtpData = {title: "Post MeetUp",error: "*Required"}; return { getMyMtpData: function () { return myMtpData; } } }); and in Controller as follows: $scope.Mtp_Data = PostMeetUpService.getMyMtpData(); {{Mtp_Data.title}} is the expression am using in HTML , but...

Change input field in angularJS

javascript,angularjs
I'm new to angularJS and want to rewrite an input field when the user presses a certain character. For example, if the user enters "aab", when the "b" is pressed I want to replace the entire field with just "y". Using ng-keypress partly works, but leaves "yb" instead of just...

Angularjs resource with scope parameter

javascript,asp.net-mvc,angularjs,single-page-application
My problem is the following: I am trying to call resource with the following parameter and I get the following error: [$resource:badcfg] I tried fixing this in the past 3 hours and I cant seem to make it work. So, if i call it like this: $scope.komintent = Fakturi.komintenti.get({ id:...

how to get ng-repeat checkbox values on submit function in angularjs

javascript,angularjs
I have a form which has 10 checkboxes. By default angular js triggers on individual checkbox. I want to grab all selected check box values on submit action only. Here is my code... <form name="thisform" novalidate data-ng-submit="booking()"> <div ng-repeat="item in items" class="standard" flex="50"> <label> <input type="checkbox" ng-model="typeValues[item._id]" value="{{item._id}}"/> {{ item.Service_Categories}}...