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将分钟添加到存储在宏变量中的时间戳(SAS Adding Minutes to a Timestamp Stored in a Macro Variable)

我发现处理这些场景的最佳方法是使用自定义日期时间格式。 你可以在这里找到建立它们的链接。 我建议将格式保存到公共库,以便它始终可用于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)

最后找到答案并将其发布到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部分,但无法找到我的流'instr...

修改SAS中宏变量的值(Modifying the value of macro variable in SAS)

如果您的周变量在数据集中彼此相邻,您可能需要考虑无宏方法: 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; 如果您的周变量以周数结束,则它们甚至不需要彼此相邻:...

如何处理SAS存储过程中的多个过滤器(How to handle multiple filters in SAS stored process)

call symputx不会附加到宏变量 - 它会覆盖它们。 因此,您需要捕获现有值作为您要设置的新值的一部分。 例如 call symputx('ID_WHERE_CLAUSE',cats(symget("ID_WHERE_CLAUSE"),'and Source = ',' &Source','')); 您需要使用symget在您的方案中执行此操作,而不是直接引用宏变量,否则可能会在先前的数据步骤执行并设置初始值之前解决它。 call symputx does not append to m...

获取SAS表中的宏变量值(Get values of Macro Variables in a SAS Table)

如果可以的话,我不明白你的编号方案并建议更改它。 &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.); ...

将数值表达式的结果存储在SAS宏变量中(Store result of numeric expression in SAS macro variable)

宏函数%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 quarte...

sas存储过程中的宏变量(Macro variable in sas stored process)

在您自己的SAS代码中,您使用宏变量username ,但在您的存储过程中,用户名在保留的宏变量_username 。 下划线实际上是变量名的一部分,所以你应该写&_username 。 有关更多信息,您可以阅读文档或在插入后查阅日志 %put _automatic_; 在您的代码中,打印所有为您提供的宏变量SAS。 备注:由于存储过程中的自动宏变量与本地SAS会话中的自动宏变量不同,如果要在两者中使用相同的代码,则通常需要一些%if %then %else逻辑。 In your own SAS...

如何在Excel中键入SAS提示值以运行存储过程?(How to type SAS prompt value in Excel to run stored process?)

你可以试试这个: 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 ...

SAS将字符表示存储在宏变量中的日期上(SAS store the character representation on a date in a macro variable)

最简单的方法是使用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));

使用硬编码证书绕过STP登录屏幕 - 从Web执行SAS存储过程(Bypass STP Login Screen Using Hard-Coded Credentials - Execute SAS Stored Process from Web)

您可以使用访客帐户为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 w...

相关文章

更多

javascript 问题

&lt;s:iterator value=&quot;list_latest_course&quot; ...

javascript的验证

在做网页时、用javascript写了许多验证、 问题是假设客户端禁用了javascript 检查 ...

请教javascript问题

&lt;script type=“javascript”&gt; function test(){ ...

javascript 基本语法

1 变量声明 var num = 10; var str = 'haha';//&quot ...

JavaScript 事件

作者:李丽媛 联系方式:lly219#gmail.com 日 期:2010-2-26 前言 ...

JavaScript 事件

作者:李丽媛 联系方式:lly219#gmail.com 日 期:2010-2-26 前言 ...

Working on Free Software

This was written in December, 1999 Lots of programm ...

javascript url编码

javascript常用的编码格式有:escape(), encodeURL(), encodeURI ...

javascript常用对象

本节的主要内容是javascript常用对象,包括Date对象、String对象和Array对象

最新问答

更多

python的访问器方法有哪些

使用方法: class A(object): def foo(self,x): #类实例方法 print "executing foo(%s,%s)"%(self,x) @classmethod def class_foo(cls,x): #类方法 print "executing class_foo(%s,%s)"%(cls,x) @staticmethod def static_foo(x): #静态方法 print "executing static_foo(%s)"%x调用方法: a =

使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)

我认为你必须将两个TableGetway传递给UserTable构造。 你必须改变Module.php看看: public function getServiceConfig() { return array( 'factories' => array( 'User\Model\UserTable' => function($sm) { $userTableGateway = $sm->get('UserTable

透明度错误IE11(Transparency bug IE11)

这是一个渲染错误,由使用透明度触发,使用bootstrap用于在聚焦控件周围放置蓝色光环的box-shadow属性。 可以通过添加以下类覆盖来解决它。 .form-control:hover { -webkit-box-shadow: 0px 0px 5px 0px rgba(0,0,255,1); -moz-box-shadow: 0px 0px 5px 0px rgba(0,0,255,1); box-shadow: 0px 0px 4px 0px rgba(0,0,255,1)

linux的基本操作命令。。。

ls 显示目录 mkdir 建立目录 cd 进入目录

响应navi重叠h1和nav上的h1链接不起作用(Responsive navi overlaps h1 and navi links on h1 isn't working)

将z-index设置为.main-nav这将解决您的重叠问题 .main-nav { position:relative; z-index:9; } set z-index to .main-nav This will fix your overlaping issue .main-nav { position:relative; z-index:9; }

在C中读取文件:“r”和“a +”标志的不同行为(Reading a File in C: different behavior for “r” and “a+” flags)

这是因为模式规范"a"打开一个文件以便追加,文件指针在末尾。 如果您尝试从此处读取,则由于文件指针位于EOF,因此没有数据。 您应该打开"r+"进行阅读和写作。 如果在写入之前读取整个文件,则在写入更多数据时,文件指针将正确定位以追加。 如果这还不够,请探索ftell()和fseek()函数。 That is because the mode spec "a" opens a file for appending, with the file pointer at the end. If you

NFC提供什么样的带宽?(What Kind of Bandwidth does NFC Provide?)

支持空中接口的数据速率是一回事。 在消除协议开销,等待eeprom写入以及所有需要时间的其他内容之后,您看到的数据速率是完全不同的故事。 长话短说,从标签读取或进行对等传输时的实际数据速率峰值约为2.5千字节/秒。 取决于具体的标签或对等技术,它可能比这慢很多。 The supported data-rates of the air-interface are one thing. The data-rate that you see after removing protocol overhe

元素上的盒子阴影行为(box-shadow behaviour on elements)

它看起来像只在Windows上的Chrome的错误。 我在Google Canary (Chrome 63)中也进行了测试,问题依然存在,所以有可能它不会很快修复。 这个问题是由overflow: auto引起的overflow: auto ,在你的情况下,它可以很容易地通过删除或设置为可见(默认)来解决。 但是 ,将鼠标悬停在右侧(顶部和底部)时,会出现滚动条。 一个解决方案可以设置overflow: hidden的身体,所以预期的结果是所需的。 我想指出,这不是一个很好的解决方案,但我建议暂

Laravel检查是否存在记录(Laravel Checking If a Record Exists)

这取决于您是否要以后与用户合作,或仅检查是否存在。 如果要使用用户对象(如果存在): $user = User::where('email', '=', Input::get('email'))->first(); if ($user === null) { // user doesn't exist } 如果你只想检查 if (User::where('email', '=', Input::get('email'))->count() > 0) { // user found

设置base64图像的大小javascript - angularjs(set size of a base64 image javascript - angularjs)

$scope.getData= function () { var reader = new FileReader(); reader.onload = $('input[type=file]')[0].files; var img = new Image(); img.src =(reader.onload[0].result); img.onload = function() { if(this.width > 640