scope

Javascript object scope - image dataurls into pdfMake

≡放荡痞女 提交于 2019-12-13 16:51:18
问题 Trying to dynamically create a pdf using pdfMake from JSON data and the report runs fine except for my images. I have tried using named keys into an object as well as pushing into an array, and even directly into the docDefinition and it appears that they contain the data on console.log but always come back undefined. The only time it actually works if I directly assign it outside of the each ( //imageData["image0"] = testDataURL; ) but this doesn't work for me as I need to get the dataurl of

Does Visual Studio 2010 C++ Fully Support in-Class const Variables?

南笙酒味 提交于 2019-12-13 15:00:49
问题 This question is closely related to a question that was previously asked here. In order for the Visual Studio 2010 C++ debugger to resolve in-class-initialized const variables, a global definition for the variable must be supplied. e.g. Here is the class definition: class B{ public: static const int m_b=100; }; Here is the global scope definition of the member: const int B::m_b; Without the global definition the code works but the debugger cannot see m_b within B's methods. However, this

Is the scope of a variable initialized in a for loop declaration actually more than just block scope?

懵懂的女人 提交于 2019-12-13 14:14:04
问题 Consider a for loop with a counter: for (int i = 0; i < 100; i++ /* `i` is visible here */) { /* `i` is visible here */ } /* `i` not visible here */ All is well. We say that i has "block" scope. However, why is it that variables declared within the for loop are not accessible at i++ ? For example, why is j not in scope here, when it also has "block" scope and was declared in a time period that is before i += j ? for (int i = 0; i < 100; i += j /* only `i` is visible here */) { int j = 1; /*

Isolating directive scope but preserve binding on ngModel

北慕城南 提交于 2019-12-13 13:18:29
问题 I have a directive that will use ng-model to expose its value. The question is that this directive have internal components that will also mess the scope, so I need to isolate its scope, but still preserve ng-model bind to outside world. How would I achieve this? This is the directive: angular.module('app', []).directive('myDirective', function() { return { restrict: 'E', require: 'ngModel', link: function(scope, element, attr, ngModel) { // do stuff using ngModel controller }, replace: true,

routing scope problem with form_for (partial)

狂风中的少年 提交于 2019-12-13 13:18:11
问题 Trying to route: scope :shortcut do resources :text_elems end Using basic scaffold with form partial *_form.html.erb* <%= form_for(@text_elem, :shortcut => @shortcut) do |f| %> ... Problem is : When I call the edit action, the form html shows as: <form ... action="/25/text_elems/25"> Note: The new action renders the form action correctly: <form ... action="/home/text_elems"> So it appears that my :shortcut param is getting trumped by the :id param when form_for processes it's block. Now I am

Better way to check if function is already bound in plain JavaScript ?

本小妞迷上赌 提交于 2019-12-13 13:18:01
问题 I'm in a situation where I would want to know if a function is already bound in order to set a warning message when that function is invoked with call or apply with a different context. function myfn (){ } /* or */ var myfn = function () {} var ref = myfn.bind(null); I checked the function object in Firefox and Chrome console and the only difference I found is that the bound version has the name prefixed with bound . > myfn.name > "myfn" > ref.name > "bound myfn" Is this a reliable check ?

Batch file variable scope issue

一曲冷凌霜 提交于 2019-12-13 13:09:04
问题 I'm having a strange variable scope issue when trying to create a 'dos' (windows 7 command line) batch file which performs a bit of string manipulation to create new file paths. Can anyone see why the OUTPUT_FILENAME variable always ends up being null in the example below? echo Enter the Data Input, S (Site) or U (User) set /p DATA_TYPE= echo. echo Enter the Input File Name set /p INPUT_FILENAME= echo. IF /I %DATA_TYPE%==u ( set OUTPUT_FILENAME=%INPUT_FILENAME:\users\=\Users\Outputs\% set

Access problem in local class

别来无恙 提交于 2019-12-13 13:05:30
问题 void foobar(){ int local; static int value; class access{ void foo(){ local = 5; /* <-- Error here */ value = 10; } }bar; } void main(){ foobar(); } Why doesn't access to local inside foo() compile? OTOH I can easily access and modify the static variable value . 回答1: Inside a local class you cannot use/access auto variables from the enclosing scope. You can use only static variables, extern variables, types, enums and functions from the enclosing scope. 回答2: From standard docs Sec 9.8.1 , A

Why I cannot declare the variable with same name that already declared but new variable is out of the scope of other variable

独自空忆成欢 提交于 2019-12-13 12:40:14
问题 private void Abc() { string first=""; ArrayList result = new ArrayList(); ArrayList secResult = new ArrayList(); foreach (string second in result) { if (first != null) { foreach (string third in secResult) { string target; } } string target;//Here I cannot decalre it. And if I don't declare it and //want to use it then also I cannot use it. And if it is in if condition like //the code commented below, then there is no any complier error. //if (first != null) //{ // string target; //} } } I

JavaScript - Return from anonymous function (varScope)

拈花ヽ惹草 提交于 2019-12-13 12:00:21
问题 <script> var sample = function() { (function() { return "something" })(); // how can I return it here again? } </script> Is there a way to return the returned value from the anonymous function in the parent function again or do I need to use a defined function to get the returned value? Thanks! :) 回答1: Just put the return statement at the point where you call the function. <script> var sample = function() { return (function() { // The function returns when you call it return "something" })();