angularjs-scope

AngularJS - directive scope not setting ng-class on element

ぃ、小莉子 提交于 2019-12-08 07:08:58
问题 Plunker I have a table of data: <table class="table table-hover" ng-class="dndElemClass" drag-and-drop> ... </table> My goal is to give the table a drop shadow by assigning $scope.dndElemClass = 'on-drag-enter' on the element's ondragenter event listener: .on-drag-enter { -webkit-box-shadow: -3px 3px 5px 3px #ccc; ... } The onDragEnter directive is as follows: directive('dragAndDrop', function() { return { restrict: 'A', controller: function($scope) { $scope.dndElemClass = ''; }, link:

How to handle multiple forms present in a single page using AngularJS

半世苍凉 提交于 2019-12-08 06:52:56
问题 I am a newbie in AngularJS. I am having multiple forms on a single page which gets displayed based on the user selection only one at a time. The DOM has two child controllers namely FirstFormController, SecondFormController wrapped under a parent controller named XceptionController . A parent controller function is used to submit the form data from both the children. The form data is saved on to the parent controller's scope.My HTML looks like below <div ng-app="app"> <div class="container"

Connect to API endpoint with Angular factory

时光毁灭记忆、已成空白 提交于 2019-12-08 06:44:46
问题 I am trying to connect with API endpoint via the simplest AngularJS snippet but have some problems which are stopping me. Here is my controller: app.controller('appController', ['$scope', 'skills', function($scope, skills) { skills.success(function(data) { $scope.skillsList = data; }); } ]); And my factory: app.factory('skills', ['$http', function($http) { return $http.get('https://www.persevy.com/skills') .success(function(data) { return data; }) .error(function(err) { return err; }); }]); I

How to pass vm to a setTimeout in AngularJs? Changes to scope don't update DOM view

点点圈 提交于 2019-12-08 06:38:18
问题 I'm trying the following code. Everything seems to be working as I see the component appear/disappear depending on the value I set for the variable. However, when I do that in the setTimeout(...) function, it starts to misbehave. The poofy text shows but the value set to vm doesn't. My guess is that I need to pass it in somehow but I'm not sure how. (function () { 'use strict'; angular .module("app") .controller("Banana", banana); function banana() { var vm = this; vm.showStuff = false;

Calculate average from list of values in JSON

跟風遠走 提交于 2019-12-08 06:33:27
问题 I have a simple ng-repeat that displays a list of values (financial income). How can i calculate the average from this list? <div ng-repeat="data in MyData"> {{ data.income }} </div> <div> Average: </div> Which displays: 11 14 8 9 21 10 2 1 5 13 Thanks 回答1: In HTML Average: {{calculateAverage(MyData)}} Code $scope.calculateAverage = function(MyData){ var sum = 0; for(var i = 0; i < MyData.length; i++){ sum += parseInt(MyData[i], 10); //don't forget to add the base } var avg = sum/MyData

Set a property of scope object dynamically in Angular Js

心已入冬 提交于 2019-12-08 05:57:48
问题 I am writing a generic method to get some data from a service and populate in the dynamic property name passed in the function. the value does gets assigned to the text box using angular.element assignment but does not gets populated in the model. following is the code. <div class="input-group"> <input class="form-control" id="ImgRollover" name="ImgRollover" ng-model="contentEntity.imgRollover" placeholder="" readonly="readonly" type="text"> <div class="input-group-btn"> <button class="btn"

Angularjs inheriting parent scope confusion

冷暖自知 提交于 2019-12-08 05:44:10
问题 I have a controller that's inside another controller. <div ng-controller="post"> <div ui-if="isAllowed"> <footer ng-controller="footer"></footer> </div> </div> I believe the ui-if creates a new scope so there's 3 scopes here. I want the footer controller to be able to access the scope of post. .controller('post', function($scope) { $scope.foo = "bar" }) I can easily do $scope.$parent.$parent.foo but I read that scopes are supposed to automatically inherit from the parent, and the parent thing

Pass variable to UI-bootstrap modal without using $scope

♀尐吖头ヾ 提交于 2019-12-08 05:28:37
问题 Since I am a beginner using AngularJS the $scope approach to pass data between different controllers and (in my case) a modal drives me crazy. Due to that reason, I googled around the web and found an interesting blogpost about passing data to a UI-bootstrap modal without using $scope . I had a deeper look at this blogpost and the delivered plunk which works pretty nice and started to adopt this to my own needs. What I want to achieve is to open a modal delivering an text input in which the

autocompleted text in textbox does not add to table completely

ε祈祈猫儿з 提交于 2019-12-08 04:57:18
问题 I am new to angularjs, I have a textbox and I have a button and table: whenever user click on add button the data in the textbox would be added to the table: here is the link to my code: code everything works fine, but when it comes to autocomplete it starts acting funny, the autocomplete itselfe works fine but if for example add acti and the autocomplete suggests actionscript then if instead of writing the whole word you choose it from suggestins just he characters that you typed would be

$scope doesn't picks up string from form input - AngularJS, JS

风格不统一 提交于 2019-12-08 04:02:31
问题 I am trying to implement Change Password feature in MVC (Rest server) application from the User Control Panel but because of some strange reason I can't scope values from form input. My html form: <accordion-group heading="Change password" is-open="changePasswordStatus.open" style="cursor: pointer"> <div> <div> <form class="form-horizontal" role="form"> <form-row model="newPassword" name="New: " size="col-sm-8"></form-row> <form-row model="repeatedNewPassword" name="Repeat: " size="col-sm-8">