dynamic-function

Dynamic function calling Angular 2

拥有回忆 提交于 2019-12-01 08:46:36
I have function name in a variable and I am assigning that variable on click event of button. but it is not working. Any Help? @Component({ selector: 'my-app', template: ` <div> <h2>Function name is: {{FunctionName}}</h2> <input type="button" value="click here" (click) = [FunctionName]()> </div> <p>{{value}}</p> `, }) export class App { FunctionName:string; value: string; constructor() { this.FunctionName = 'clickFunction' } clickFunction(){ this.value = "button clicked"; } } Here is the code Plunker Code Syntax needs to be like this: <input type="button" value="click here" (click) ="this

Dynamic function calling Angular 2

China☆狼群 提交于 2019-12-01 06:59:03
问题 I have function name in a variable and I am assigning that variable on click event of button. but it is not working. Any Help? @Component({ selector: 'my-app', template: ` <div> <h2>Function name is: {{FunctionName}}</h2> <input type="button" value="click here" (click) = [FunctionName]()> </div> <p>{{value}}</p> `, }) export class App { FunctionName:string; value: string; constructor() { this.FunctionName = 'clickFunction' } clickFunction(){ this.value = "button clicked"; } } Here is the code

__callStatic(), call_user_func_array(), references, and PHP 5.3.1

[亡魂溺海] 提交于 2019-11-30 03:46:46
问题 I've been reading around on SO, and elsewhere, however I can't seem to find anything conclusive. Is there any way to effectively carry references through this call stack, resulting in the desired functionality as described in the example below? While the example doesn't try to solve it, it certainly illustrates the problem: class TestClass{ // surely __call would result similarly public static function __callStatic($function, $arguments){ return call_user_func_array($function, $arguments); }

Python dynamic function creation with custom names

南楼画角 提交于 2019-11-27 04:28:21
Apologies if this question has already been raised and answered. What I need to do is very simple in concept, but unfortunately I have not been able to find an answer for it online. I need to create dynamic functions in Python (Python2.7) with custom names at runtime. The body of each function also needs to be constructed at runtime but it is (almost) the same for all functions. I start off with a list of names. func_names = ["func1", "func2", "func3"] Note that the func_name list can hold a list of arbitrary names, so the names will NOT simply be func1, func2, func3, .... I want the outcome

How to define a dynamic mixin or function name in SASS?

我与影子孤独终老i 提交于 2019-11-26 14:30:49
问题 I want to dynamically create mixins in SASS, named after each item in the list, but it doesn't seem to work. I tried this but I get an error: $event-icons: fair, concert, art-show, conference, dance-show, film, party, festival, theatre, launch @each $event-icon in $event-icons @mixin event-icon-#{$event-icon} background-position: -($event-icon-width * $i) 0 Error: Invalid CSS after "": expected expression (e.g. 1px, bold), was "#{$event-icon}" Is this usage not supported by SASS? I couldn't

Python dynamic function creation with custom names

人走茶凉 提交于 2019-11-26 12:26:59
问题 Apologies if this question has already been raised and answered. What I need to do is very simple in concept, but unfortunately I have not been able to find an answer for it online. I need to create dynamic functions in Python (Python2.7) with custom names at runtime. The body of each function also needs to be constructed at runtime but it is (almost) the same for all functions. I start off with a list of names. func_names = [\"func1\", \"func2\", \"func3\"] Note that the func_name list can

How to call a function from a string stored in a variable?

僤鯓⒐⒋嵵緔 提交于 2019-11-26 05:49:08
问题 I need to be able to call a function, but the function name is stored in a variable, is this possible? e.g: function foo () { //code here } function bar () { //code here } $functionName = \"foo\"; // i need to call the function based on what is $functionName 回答1: $functionName() or call_user_func($functionName) 回答2: My favorite version is the inline version: ${"variableName"} = 12; $className->{"propertyName"}; $className->{"methodName"}(); StaticClass::${"propertyName"}; StaticClass::{