scope

angular scoped variable in controller not updating when value changed in service

假如想象 提交于 2019-12-11 07:17:43
问题 I'm developing a mini-basket in angular for an ecommerce application but have a problem with a scoped variable not updating via a service. When i click on an add to basket button in the product grid it fires the upDateMiniBasket function in the product grid controller which has the UpdateMiniBasket service injected into it. The controller: whiskyControllers.controller('whiskyListCtrlr', ['$scope', 'UpdateMiniBasket', '$http', function($scope, UpdateMiniBasket, $http){ $http.get('json/whiskies

How to exit a function scope from inner function using Swift?

*爱你&永不变心* 提交于 2019-12-11 06:26:42
问题 With return it is possible to exit the scope of the current function but is it also possible to exit the scope of the outer function that is calling the inner function? func innerFunction() { guard 1 == 2 else { // exit scope of innerFunction and outerFunction } } func outerFunction() { innerFunction() print("should be unreachable") } There could be one approach using a return value of the inner function that we can check for: func innerFunction() -> Bool { guard 1 == 2 else { return false }

Angular directive scope between google maps and a controller

烂漫一生 提交于 2019-12-11 06:16:16
问题 The following code finds the current users iPhone geolocation on load and loads a google map accordingly using a directive. Unfortunately the geolocationData data variable from the directive does not get shared to the html footer {{geolocationData}}... So how can I pass in this case the geolocationData across from the directive to the html page and/or the controller. Thank you. Directive: 'use strict'; angular.module('MyApp.directives', ['ngCordova']) .directive('map', function(

Passing Parameters to KeyDown

血红的双手。 提交于 2019-12-11 06:12:23
问题 How can you pass parameters into the keydown method from jquery because whenever I use a variable defined elsewhere it returns undefined. I assume its because the #target is window and therefore its not in the scope but even then I have trouble getting it to compare the key.which() with an outside parameter and then assigning it to another property. Example: var a = 38; var b = 0; $(document).keydown(function(e){ var key = e.which; if (a==key) b=key; }); console.log(a+""+b); Whenever I try to

Javascript scoping Issue using JQuery Boilerplate

情到浓时终转凉″ 提交于 2019-12-11 06:09:38
问题 I am using the JQuery Boilerplate to write my first JQuery plugin - a responsive carousel. I am using another plugin (SSM - http://www.simplestatemanager.com/) to create states for each device view. So on mobile devices functionA will run, on tablets functionB and on desktops functionC, etc. For each state created by SSM a corresponding onEnter callback function can be added and I've added 3 suitable functions to run when this occurs. As you can see from the code below a function

Form filter on index page using cross-model scope

我们两清 提交于 2019-12-11 06:09:25
问题 I want to filter an index page using a form that filters using checkboxes without refreshing the page. It's the Users index but I'm filtering depending on Profile data. I'm a beginner to programming and have managed to piece together some of what I'm trying to do but need help connecting it all. (For reference, for guidance on scopes I used this article and for the form/ajax/jQuery I used this article.) User.rb: class User < ActiveRecord::Base has_one :profile, :dependent => :destroy scope

Javascript Redirect with SetTimout Not Working

♀尐吖头ヾ 提交于 2019-12-11 05:46:14
问题 Can't seem to get this javascript redirect to work? Suggestions? Should I maybe do it with a meta refresh and how? // If we have a successful location update function onGeoSuccess(event) { document.getElementById("Latitude").value = event.coords.latitude; document.getElementById("Longitude").value = event.coords.longitude; document.getElementById("location").href = "track.cfm?track=s&Lat=" + event.coords.latitude + "&Long=" + event.coords.longitude; var redirectUrl = "track.cfm?track=s&Lat="

trouble accessing external float array

陌路散爱 提交于 2019-12-11 05:14:43
问题 I have the following program in two files main.cpp float POW10[300]; main(0 { Fill_POW10(); } Fill.cpp extern float *POW10; Fill_POW10() { for(int i=0;i<300;i++) { POW10[i]=i; } } This crashed with a segmentation fault. When I inspect, POW10 is NULL. However if I change Fill.cpp to extern float POW10[]; Fill_POW10() { for(int i=0;i<300;i++) { POW10[i]=i; } } the code works fine. I was thinking that POW10 is actually implemented as a pointer to floats and so the codes should be identical. Can

array.length is zero, but the array has elements in it [duplicate]

南笙酒味 提交于 2019-12-11 05:14:21
问题 This question already has answers here : Is Chrome's JavaScript console lazy about evaluating arrays? (6 answers) Closed last year . I'm currently in the process practicing using electron, but I'm quite new with javascript and I've come across a problem which has me completely baffled. I have the following code: function getPaths() { var dirPath = document.getElementById("mdir").innerHTML; var filePaths = []; fs.readdir(dirPath, function(err, dir) { for(var i = 0, l = dir.length; i < l; i++)

Refering to a variable of the data frame passed in the 'data' parameter of ggplot function

萝らか妹 提交于 2019-12-11 05:14:18
问题 I would like to use a variable of the dataframe passed to the data parameter of function the ggplot in another ggplot2 function in the same call. For instance, in the following example I want to refer to the variable x in the dataframe passed to the data parameter in ggplot in another function scale_x_continuous such as in: library(ggplot2) set.seed(2017) samp <- sample(x = 20, size= 1000, replace = T) ggplot(data = data.frame(x = samp), mapping = aes(x = x)) + geom_bar() + scale_x_continuous