I have written a custom module which creates a block. I invoke the block from a template file using the following code.
$block = module_invoke('my_mod', 'block_view', 'block_1a', $an_argument);
print $block['content'];
I need to access $an_argument in the module when the block is created.
How can I access the argument I pass to the block when it's invoked?
I believe you would have to implement the hook_block_view to handle your argument.
The api docs for hook_block_view
Related
I have a working skill that uses the function that checks whether the alexa device has a display so I can either build a template output or render output to a card:
function supportsDisplay() {
var hasDisplay =
this.event.context &&
this.event.context.System &&
this.event.context.System.device &&
this.event.context.System.device.supportedInterfaces &&
this.event.context.System.device.supportedInterfaces.Display
return hasDisplay;
}
I have a couple places where I render output so I wanted to make a function I can call to handle the visual output instead of having to rewrite the template code multiple times.
This returns an error. If I use this same function but comment out the call to the supportsDisplay function it works, so I assume the problem is in how I'm calling it:
function makeTemplate(playStatus){
if (supportsDisplay.call(this)){...}
return;
}
I also tried not making a function to check the display at all and actually just putting the code to check it directly in my function but that also didn't work.
I'm guessing part of the problem could be the this keyword (I'm very new to JS/Alexa dev and don't understand really what "this" does.
Is there a way to be able to call that supportsDisplay function from within my function? What would be the syntax do that?
I've got basic variable that I'm getting from my api:
nurseListSpeciality.avatar = "srcs[14]"
I want to change srcs[14] into array name, that my object should be like:
nurseListSpeciality:[{avatar: srcs[14]}]
The main problem is that I don't want to execute the reference on the array, but I want to put just a name of it inside my object.
This is why I failed to use eval(). Eval is trying to get srcs[14] value and put it into my object. This is not what I want.
If you're open to use lodash, using _.get is a good way to do this:
nurseListSpeciality.avatar = _.get(window, "srcs[14]");
This code assumes that srcs is a variable which is available globally (in window object). If you have some other scope, you should replace window with the appropriate object.
vuejs console gives:
Uncaught (in promise) TypeError: this.nurseListSpeciality[i].eval is
not a function
Error message tells you that this.nurseListSpeciality[i] doesn't have an eval method, you need to invoke global eval on this.nurseListSpeciality[i].avatar as.
eval(this.nurseListSpeciality[i].avatar)
Note
This will not work if you don't have a variable srcs available in your current scope.
I'm creating a simple web page where i display a button which execute this code
$window.open(link, "_self");
The link variable is a simple telegram link for a channel, but this is not the problem, the problem, as the question say itself, is about arguments variable in $window.open.
This in my opinion is strange because when i logged in the console $window.open function, i received this output:
function pbWindowOpen() {
lastBlockCaller = {
caller: arguments.callee.caller,
args: arguments.callee.caller.arguments
};
try {
return newWindowOpenFn.apply(this, argument…
At this point, should not i see an argument variable inside this function? How could i solve this problem?
Passing some arguments could resolve my problem? If yes, there's an answer about why i'm having arguments null?
I've also tried with window.open but nothing changes, always the same problem
That shouldn't happen if you are running your code in a browser (in other env you may have some initialized variable window representing something else), $window is a wrapper in top of var currWindow = $window.self || $window.window and then do a perform of callong open(...) function. Hence, you neither using the native javascript code badly in a angular context, and again that would be easily mock-ableif we mock $window and create a property call self or window inside it. So it will work in the application, and will also be testable.
I am trying to set up some app wide constants from a http endpoint. I don't want (or need ) to do it via the manual bootstrap way (ala this ). Ideally I want to load the constants in after the user has signed in. So I assume I need to define the constants somewhere I can run some code (and use $http). But whenever I define a constant inside a controller or a config block, the constant gives an unknown provider error when I pass it into another module. As soon as I move the definition outside of the controller it works. So for example, if I have ...
var app = angular.module('testApp',[]);
app.constant('test', 'test value');
then I can pass that into another module's controller like this:
var app2 = angular.module('anotherModule',[testApp]);
app2.controller('TestCtrl', ['test',
function(test) {
console.log(test)`
}..
and this will output 'test value' as you would expect. But if the constant is defined inside a code block then it seems it doesn't register as a provider. So, for example:
var app = angular.module('testApp',[]);
app.controller('firstCtrl',function(){
app.constant('test', 'test value');
}
If I run a page with that controller, the constant seems to register (in the sense that it is listed inside the _invokeQueue array on the testApp module) but the injector service doesn't have a provider for it and I get an unknown provider method for it on anotherModule.
I initially felt that a factory or service was overkill for what I was trying to do but maybe that is the way I should go. But I would also love to understand why a constant defined like this isn't injectable.
Easiest way to load constants for HTML5 app:
add the following line into head section:
< script src="service/constants.js">
create web api / wcf / java REST service method with signature "service/constants.js"
in that method return "window.constants = {...}".
replace "..." with actual key:value pairs read from database.
I am trying to see the value of a variable inside a function when the execution is paused at a debug point inside the function using chrome's developer tools .I selected/hovered over the variable but the tooltip with the value is not appearing unlike normal javascript function in other js files.
try type the variable name in console window, you should be able to see what is the variable value.
example :
Select the whole variable name and hover it again.