angularjs-scope

How to transfer $scope.variables to controller?

痞子三分冷 提交于 2019-12-12 00:08:51
问题 I am building a system where i have items listed in a list with variables Title Skills Budget Posted I also have a Modal that opens up when i click on an item in the list. I would like to take the current selected item and use its variables in my second modal controller? Is this possible? I was thinking of using a service where i cache all data that is pulled from database, but then i dont know how i would only display selected item and not EVERY item in the modal. Here is my controller for

How do I use a legacy javascript library as a scoped dependency of an Angular service?

不羁的心 提交于 2019-12-11 23:13:25
问题 Specifically, I am working with an ~800 line SCORM API wrapper library that facilitates communication with an LMS. The author did not write it in Angular. A legacy, vanilla js file(index.js) has been wrapped over top of it I'm including a snippet of both to give an idea of the structure being used here. SCORM = { //Define the SCORM object version: null, //Store SCORM version. handleCompletionStatus: true, //Whether or not the wrapper should automatically handle the initial completion status

angular.js Getting the element from inside $evalAsync in directive

。_饼干妹妹 提交于 2019-12-11 23:12:53
问题 I'm finding that I'm using scope.$evalAsync inside a directive quite a lot. Mainly to do DOM stuff/jquery plugins that need all the template {{vars}} compiled. I can get at the scope object from inside $evalAsync but not the element. In latest case in question, I'm manipulating an element that gets rendered with an ngRepeat. I'm currently getting the element by composing a jquery selector based on the scope object e.g. scope.$evalAsync(function (scope) { $("#item-" + scope.id).runJQplugin();

Angular directive, binding click event to outside element not working

馋奶兔 提交于 2019-12-11 22:36:45
问题 I am trying to create a custom event for toggling with Angular. The directive is called toggleable. It sounds trivial at first, but tricky bit is that i want to be able to to use any button or link on the page for toggling. The code i have written is as below Directive 'use strict'; angular.module('onsComponents') .directive('togglable', function() { return { restrict: 'A', transclude: true, scope: { togglerId: '@', show: '@' }, link: function(scope, element, attrs) { if (!scope.togglerId) {

Angularjs - Result is not updating when new create data has been added

谁都会走 提交于 2019-12-11 22:22:32
问题 I know it have been asked here, but I'm still blocked with this issue where the result are not updating after i added a new data to the database. I have one controller for adding and retrieving data .controller('GameCtrl', ['$scope', function(scope) { scope.createGame = function() { Api.createGame(postData).then(function(result) { console.log(result); scope.$broadcast("event: list updated", true); }, function(result) { console.log(result.data.message); scope.showError = true; scope.data =

How to add icon on row in ionic framework?

懵懂的女人 提交于 2019-12-11 20:47:00
问题 I am trying to make simple demo in ionic. I have one footer having one icon ion-compose (bottom left icon). When I click on that icon it show a pop up screen I enter name in text field and press save button. Then it generates a row which have same text as written in textfield of popup screen. I need to add icon buttons on row (like delete button, edit button). Can we add icon on dynamically generated row as I did in footer (bottom left ion-composer)? Please add ion on row Here is my code http

How to add new key in existing array in angular js?

天大地大妈咪最大 提交于 2019-12-11 20:34:24
问题 I have define blank array $scope.order, ON form submit data get and create new array then merge with existing array. .controller('GuestDetailsCtrl',function($scope){ $scope.order = []; $scope.itemDetails = function() { // Here data get after form submiti have array arrieve from form submit. $scope.order=$scope.order.push({name:$scope.item.name,price:$scope.item.price}); } }); I want result like this. $scope.order = [{name:'abc',price:100},{name:'pqr',price:80},{name:'xyz',price:50}]; When

angularjs promise not resolving properly

自闭症网瘾萝莉.ら 提交于 2019-12-11 19:35:24
问题 My controller has all the required dependencies injected. $scope.connect = function(url) { var defer = $q.defer(); var promise = $http.get(url).then(function (response) { $timeout(function(){ defer.resolve(response); },10000); defer.resolve(response); $scope.$apply(); //$rootScope.$apply(); }); return defer.promise; }; $scope.mymethod = function(){ $scope.globalMydata[]; console.log("before the http get"); $scope.connect("MY_URL").then(function(data) { console.log("called!", data); console

Get dynamic scope variable value angularjs

痴心易碎 提交于 2019-12-11 19:26:06
问题 I have array of object which contains number of scope variable name in it. All the scope variable value has already been set before. Something like this : $scope.myarray = [{'id':'myname1'},{'id':'myname2'}]; $scope.myname1 = 'John'; $scope.myname2 = 'Rick'; Now if I want to get value of the scope variable which within the 'id' of 'myarray',what should I do? I have already tried this var getMeMyValue = $scope[myarray[0]]; Something like this,but it didnt help. I have seen in this example that

AngularJS : Testing directive, HTML not re-rendered after promise completion

强颜欢笑 提交于 2019-12-11 19:07:14
问题 I am writing some basic unit tests for my AngularJS app. I have some bindings on the UI with a scope variable inside my directive whichis populated on the completion of a promise. HTML: <div id="parent"> <div id="child" ng-repeat="l in aud"> // Other Stuff </div> </div> Directive: link: function(scope){ service.getArray().$promise.then(function(data){ scope.aud = data; } Test: describe('my module', function () { var $compile: ICompileService, $rootScope: IScope, directive: JQuery<HTMLElement>