是否有可能有类似的概念ngFor或ng-repeatjQuery中或香草JS?
想做类似的事情,但不是以有角度的方式。
<div *ngFor="let inputSearch of searchBoxCount" class="col-sm-12">
<textarea name="{{inputSearch.name}}" id="{{inputSearch.name}}" rows="2" class="search-area-txt" attr.placeholder="{{placeholder}} {{inputSearch.name}}">
</textarea>
</div>
Run Code Online (Sandbox Code Playgroud)
也许与data=""属性一起使用,以有意义的为准。
是否可以在执行时更改安装依赖项的位置npm install -g module?我知道它安装在您的设备中,C:/../{name}/Appdata..etc但由于磁盘空间有限,我想更改我的路径。
我已经在外部磁盘上安装了 node.js,这很好并且可以执行 npm 命令,但现在我希望全局依赖项也安装在这个磁盘上。
有没有办法做到这一点?
我正在测试 VisJS 的网络图,我正在尝试找到一种将图像放入形状方形节点中的方法。我知道形状可以指定为,image但这只会使节点成为图像。
示例:此示例仅使用带有文本的常规节点形状,并希望在形状内添加图像。http://visjs.org/examples/network/nodeStyles/widthHeight.html
我的示例:我希望John Smith猫图像和标签位于方形节点中。
http://plnkr.co/edit/nKqOWWSu1yWxx3bPdHUw?p=preview。
想知道是否可以将text和image放在方形节点内?
如何从中删除元素ngFor?我有这样ngFor的项目,Id我正在传递updateOrder()函数,所以它知道我点击了哪个项目.
getOrdersFromOrigin() {
this.sharedService.getOriginSite()
.subscribe(data => {
this.isLoading = false;
this.orderPreparing = data.Results
})
}
<div class="preparing" *ngFor="let prepare of orderPreparing">
<p> {{ prepare.Item }} </p>
<button class="btn btn-primary" (click)="updateOrder(prepare.Id)">It's Ready</button>
</div>
Run Code Online (Sandbox Code Playgroud)
在我的updateOrderupdateOrder函数中我没有任何东西,因为我不确定如何删除相对于Id我在(click)=""事件中传递的元素,它给了我Id很好的.
这updateOrder()是有效的,因为它从UI中删除它,但想法是一旦删除我想将它添加到集合.
updateOrder(id) {
for(let i = 0; i < this.orderPreparing.length; i++) {
if (this.orderPreparing[i].Id === id) {
this.orderPreparing.splice(i, 1);
this.addToCollection.push(this.orderPreparing[i]);
console.log(this.addToCollection);
console.log('Changed Status to AwaitingToPick');
break;
}
}
} …Run Code Online (Sandbox Code Playgroud) 改写我之前的问题,我有这条路线,它给了我这样的东西 /order-screen/store/1/London
{
path: 'order-screen/store/:storeId/:storeLocation',
component: OrderComponent
}
Run Code Online (Sandbox Code Playgroud)
当我尝试storeLocation使用this.route.params它时,它会返回NaN. 我想知道位置London,不确定是否.params适合使用。
this.routeSub = this.route.params.subscribe(params => {
this.storeLocation = +params['storeLocation'];
console.log('Location >> ', this.storeLocation);
})
Run Code Online (Sandbox Code Playgroud) 您如何允许input type="number"接受类似的内容,1, 2, 3, 55而不只是接受number带小数的常规内容。
我尝试使用模式,但是它似乎并没有发挥作用,因为它仍然只接受数字和小数。
Example:
<input type="number" pattern="[0-9]+([\.,][0-9]+)?">
Desired:
<input type="text" pattern="[0-9]+([\.,][0-9]+)?" value="1, 2, 3, 4">Run Code Online (Sandbox Code Playgroud)
<input type="number" pattern="[0-9]+([\.,][0-9]+)?">
Run Code Online (Sandbox Code Playgroud) 我一直在尝试将数组的数字列表与数字input值匹配,但每次进入循环时,它似乎根本找不到匹配.所以场景是如果input2匹配任何值,input1那么它应该显示在中的警报if statements.
我错过了一些非常明显的东西吗?
var inputValues = ["1", "2", "3", "4", "5"]
var input1Val = $("#input1").val(inputValues);
function saveBtn() {
var input2Val = $('#input2').val();
var isMatched = false;
for (var i = 0; i < inputValues.length; i++) {
if(inputValues[i] === input2Val) {
var isMatched = true;
} else {
isMatched = false;
}
}
if(isMatched) {
alert('is matched and should save');
} else {
alert('Is not matched! Error!');
}
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" …Run Code Online (Sandbox Code Playgroud)