简体   繁体   English

是否可以在运行时更改AngularJS变量的类型?

[英]Is it possible to change the type of an AngularJS variable in run time?

Is it possible to change the type of an AngularJS variable in run time? 是否可以在运行时更改AngularJS变量的类型?

$scope.addedDate = $scope.model.AddedDate;
$scope.addedDate = new Date();

$scope.addedDate is created by assigning @scope.model.AddedDate and its a string field and I want to convert @scope.AddedDate into a date field. $ scope.addedDate是通过分配@ scope.model.AddedDate及其字符串字段创建的,我想将@ scope.AddedDate转换为日期字段。

Javascript engine is a interpreter which will assign the type to the variable based on the latest value it holds. Javascript引擎是一个解释器,它将根据其拥有的最新值将类型分配给变量。 Angularjs also Javascript :) Angularjs也使用Javascript :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM