首页 \ 问答 \ ng-如果不使用简单的javascript(ng-if not working with simple javascript)

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 of bool changes, but same doesn't happens with simple JS button . Actually I am implementing Angular in a page that already uses jQuery, so I need to use simple JS button.

JS Fiddle : JS Fiddle


原文:https://stackoverflow.com/questions/43142237
更新时间:2024-04-21 21:04

最满意答案

在您自己的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社区( 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 ...
  • 最简单的方法是使用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 ...

相关文章

更多

最新问答

更多
  • 带有简单redis应用程序的Node.js抛出“未处理的错误”(Node.js with simple redis application throwing 'unhandled error')
  • 高考完可以去做些什么?注意什么?
  • Allauth不会保存其他字段(Allauth will not save additional fields)
  • Flask中的自定义中止映射/异常(Custom abort mapping/exceptions in Flask)
  • sed没有按预期工作,从字符串中间删除特殊字符(sed not working as expected, removing special character from middle of string)
  • 怎么在《我的世界》游戏里面编程
  • .NET可移植可执行文件VS .NET程序集(.NET Portable Executable File VS .NET Assembly)
  • 搜索字符串从视图中键入两个字段的“名字”和“姓氏”组合(Search Strings Typed from View for Two Fields 'First Name' and 'Last Name' Combined)
  • 我可以通过配置切换.Net缓存提供程序(Can I switch out .Net cache provider through configuration)
  • 在鼠标悬停或调整浏览器大小之前,内容不会加载(Content Does Not Load Until Mouse Hover or Resizing Browser)
  • 未捕获的TypeError:auth.get不是函数(Uncaught TypeError: auth.get is not a function)
  • 如何使用变量值创建参数类(How to create a parameter class with variant value)
  • 在std :: deque上并行化std :: replace(Parallelizing std::replace on std::deque)
  • 单元测试返回Connection对象的方法(Unit Test for a method that returns a Connection object)
  • rails:上传图片时ios中的服务器内部错误(rails: server internal error in ios while uploading image)
  • 如何在Android中构建应用程序警报[关闭](How build an application Alarm in Android [closed])
  • 以编程方式连接到Windows Mobile上的蓝牙耳机(Programmatically connect to bluetooth headsets on Windows Mobile)
  • 在两个不同的SharedPreference中编写并获得相同的结果(Writing in two different SharedPreference and getting the same result)
  • CSS修复容器和溢出元素(CSS Fix container and overflow elements)
  • 在'x','y','z'迭代上追加数组(Append array on 'x', 'y', 'z' iteration)
  • 我在哪里可以看到使用c ++源代码的UML方案示例[关闭](Where I can see examples of UML schemes with c++ source [closed])
  • SQL多个连接在与where子句相同的表上(SQL Multiple Joins on same table with where clause)
  • 位字段并集的大小,其成员数多于其大小(Size of bit-field union which has more members than its size)
  • 我安装了熊猫,但它不起作用(I installed pandas but it is not working)
  • Composer - 更改它在env中使用的PHP版本(Composer - Changing the version of PHP it uses in the env)
  • 使用JavaFX和Event获取鼠标位置(Getting a mouse position with JavaFX and Event)
  • 函数调用可以重新排序(Can function calls be reordered)
  • 关于“一对多”关系的NoSQL数据建模(NoSQL Data Modeling about “one to many” relationships)
  • 如何解释SBT错误消息(How to interpret SBT error messages)
  • 调试模式下的Sqlite编译器错误“初始化程序不是常量”(Sqlite compiler errors in Debug mode “initializer is not a constant”)