ng-如果不使用简单的javascript(ng-if not working with simple javascript)
当我通过简单的javascript函数更改值时,ng-if不起作用。我的函数被调用但是在视图中看不到值的更改。 请参考以下代码。
HTML
<div id="span" ng-app='MyModule' ng-cloak ng-controller="MyController"> <div ng-if="!bool"> This is for true </div> <div ng-if="bool"> This is False </div> {{bool}} <br> <input type="submit" ng-click = "myfunction('test')" value="ng-if button"> </div> <input type="submit" onClick = "check1()" value="simple JS button">
JS
angular.module('MyModule', []) .controller('MyController', function ($scope) { $scope.bool = true; $scope.myfunction = function (data) { $scope.bool = !$scope.bool; }; }); function check1() { angular.element(document.getElementById('span')).scope().myfunction('test'); }
当我使用
ng-click button
它会改变bool
变化的值,但是simple JS button
不会发生同样的情况。 实际上我在已经使用jQuery的页面中实现Angular,所以我需要使用simple JS button
。JS小提琴 : JS小提琴
ng-if is not working when I change the values through simple javascript function.My function is getting called but the changes in values cannot be seen in view. Please refer below code.
HTML
<div id="span" ng-app='MyModule' ng-cloak ng-controller="MyController"> <div ng-if="!bool"> This is for true </div> <div ng-if="bool"> This is False </div> {{bool}} <br> <input type="submit" ng-click = "myfunction('test')" value="ng-if button"> </div> <input type="submit" onClick = "check1()" value="simple JS button">
JS
angular.module('MyModule', []) .controller('MyController', function ($scope) { $scope.bool = true; $scope.myfunction = function (data) { $scope.bool = !$scope.bool; }; }); function check1() { angular.element(document.getElementById('span')).scope().myfunction('test'); }
When I use
ng-click button
it changes value ofbool
changes, but same doesn't happens withsimple JS button
. Actually I am implementing Angular in a page that already uses jQuery, so I need to usesimple JS button
.JS Fiddle : JS Fiddle
原文:https://stackoverflow.com/questions/43142237
最满意答案
在您自己的SAS代码中,您使用宏变量
username
,但在您的存储过程中,用户名在保留的宏变量_username
。 下划线实际上是变量名的一部分,所以你应该写&_username
。有关更多信息,您可以阅读文档或在插入后查阅日志
%put _automatic_;
在您的代码中,打印所有为您提供的宏变量SAS。
备注:由于存储过程中的自动宏变量与本地SAS会话中的自动宏变量不同,如果要在两者中使用相同的代码,则通常需要一些
%if %then %else
逻辑。In your own SAS code, you use a macro variable
username
, but in your stored process, the user name is available in the reserved macro variable_username
. The underscore is really part of the variable name, so you should write&_username
.For more information, you can read the documentation or you can consult the log after inserting
%put _automatic_;
in your code, to print all macro variables SAS provided for you.
Remark: As the automatic macro variables in a stored process differ from that in a local SAS session, if you want to use the same code in both, you often need some
%if %then %else
logic.
相关问答
更多-
我发现处理这些场景的最佳方法是使用自定义日期时间格式。 你可以在这里找到建立它们的链接。 我建议将格式保存到公共库,以便它始终可用于SAS会话。 格式为: proc format ; picture mssqldt low-high = '''%Y-%0m-%0d %0H:%0M:%0S.000''' (datatype = datetime) ; run ; 这将采用常规SAS日期时间戳并将其格式化(包括引号): '2015-09-21 15:04:16.000' 将此功能合并到SAS代码中的最佳 ...
-
SAS存储过程的XML语法(XML Syntax for SAS Stored Process)[2022-12-24]
最后找到答案并将其发布到SAS社区( https://communities.sas.com/t5/SAS-Stored-Processes/Help-with-XML-Syntax-for-post-request-to-Stored-Process / mp / 239032 / highlight / false#M3304 ) 不幸的是,这些文档严重缺乏通过普通XML发送数据流的具体例子。 我最初试图在文档的XMLA部分中插入独立示例SOAP请求的纯XML部分,但无法找到我的流'instream'。 ... -
如果您的周变量在数据集中彼此相邻,您可能需要考虑无宏方法: data sasdata1.dataone; set sasdata1.dataone; sum = sum(of _W1_NRX--_W53_NRX); *double dash means that the columns are next to each other with _W1_NRX as first and _W53_NRX as last; run; 如果您的周变量以周数结束,则它们甚至不需要彼此相邻: data ...
-
call symputx不会附加到宏变量 - 它会覆盖它们。 因此,您需要捕获现有值作为您要设置的新值的一部分。 例如 call symputx('ID_WHERE_CLAUSE',cats(symget("ID_WHERE_CLAUSE"),'and Source = ',' &Source','')); 您需要使用symget在您的方案中执行此操作,而不是直接引用宏变量,否则可能会在先前的数据步骤执行并设置初始值之前解决它。 call symputx does not append to macro ...
-
如果可以的话,我不明白你的编号方案并建议更改它。 &var_变量非常混乱。 无论如何,最简单的方法是SYMGET 。 它返回宏符号表中的值,您可以在运行时指定该值。 %let VAR_0=3; %let VAR_=2; %let VAR_1=5; %let VAR_2=7; data want; do obs = 1 to &var_0.; var = input(symget(cats('VAR_',ifc(obs=1,'',put(obs-1,2.)))),2.); outpu ...
-
宏函数%eval()允许您使用整数宏变量执行算术运算。 尝试这个: %do quarter = 0 %to 3; %let macro_variable = %eval(&quarter. *3); %end; 如果需要非整数计算,则将%eval替换为使用浮点运算的%sysevalf The macro function %eval() lets you perform arithmetic with integer macro variables. Try this: %do quarter = 0 ...
-
在您自己的SAS代码中,您使用宏变量username ,但在您的存储过程中,用户名在保留的宏变量_username 。 下划线实际上是变量名的一部分,所以你应该写&_username 。 有关更多信息,您可以阅读文档或在插入后查阅日志 %put _automatic_; 在您的代码中,打印所有为您提供的宏变量SAS。 备注:由于存储过程中的自动宏变量与本地SAS会话中的自动宏变量不同,如果要在两者中使用相同的代码,则通常需要一些%if %then %else逻辑。 In your own SAS code ...
-
你可以试试这个: Sub InsertStoredProcessWithPrompts() Dim sas As SASExcelAddIn Set sas = Application.COMAddIns.Item("SAS.ExcelAddIn").Object Dim prompts As SASPrompts Set prompts = New SASPrompts prompts.Add "EUID", activesheet.cells(1,2).value 'This is cell B1 Di ...
-
SAS将字符表示存储在宏变量中的日期上(SAS store the character representation on a date in a macro variable)[2023-12-21]
最简单的方法是使用VVALUE函数,该函数返回格式化的值 call symput('dtBourse'||left(_N_),vvalue(DATE)); The easiest way is to use the VVALUE function, which returns the formatted value call symput('dtBourse'||left(_N_),vvalue(DATE)); -
您可以使用访客帐户为webanon@saspw用户运行存储过程,但如果此用户未在环境中显示,则应该执行额外的配置。 你可以像这样运行一个存储过程: http://server-name.com:8080/SASStoredProcess/guest?_program=/path/to/program 使用此链接,您将自动以webanon@saspw用户webanon@saspw登录。 You can use a guest account to run a stored process for webano ...