我一直在做很多研究,但找不到好的解决方案.基本上,我在我的应用程序中有一个面板,(Panel 2)并且想要在单击按钮时将其折叠到左侧,如果再次单击该按钮,则将其展开到右侧.
这是我的工作代码: PLUNKER
<div fxFlex fxLayout="row" fxLayoutAlign="space-between stretch" style="background-color:green;">
<div fxFlex [fxShow]="explorerShow" style="background-color:white;">
<div (click)="toggleDirection()" > <img src="../../../assets/images/button1.png" alt="Button" style = 'float: right'>
</div>
Panel 2
</div>
Run Code Online (Sandbox Code Playgroud) 我正在尝试从另一个组件执行一个函数(这两个组件不是兄弟组件)。我的猜测是,我需要使用@Output 和 eventEmitter来完成此任务,或者创建一个Service并订阅Observable以在所有组件中共享相同的数据(我知道如何传递消息(字符串),但我不知道)知道如何执行函数)。我不太确定从哪里开始。我正在尝试从function2执行function1。谁能帮助我如何让它发挥作用?请提供一个plunker。这就是我的项目的样子:
src
|__app(FOLDER)
|__home(FOLDER)
| |
| |__home.component.ts
| |______function2(){
| What do I need to put in here to execute function1?
| }
|
|__products(FOLDER)
|
|__tools(FOLDER)
|
|____tools.component.ts
|____function1(){
alert("I'm inside function 1!!");
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我有一个包含 function2 的文件home.component.ts和一个包含 function1 的文件tools.component.ts ,那么有什么想法如何从 function2 执行 function1 吗?
我有一个网格,如果名称等于"Beto Carlx",我想添加一棵树有谁知道怎么做到这一点?先感谢您!
这是我的代码:LIVE DEMO
columns: [{
header: 'NAME',
renderer: function(val, metadata, record) {
var recordName = record.get('name');
if (recordName === "Beto carlx") {
return "TEST";
}
return recordName;
},
dataIndex: 'name',
}],
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用这个简单的树:
var store = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
children: [
{ text: "Beto carlx", expanded: true, children: [
{ text: "item 1", leaf: true },
{ text: "item 2", leaf: true}
] }
]
}
});
Ext.create('Ext.tree.Panel', {
width: 200,
height: 150,
store: store,
rootVisible: …Run Code Online (Sandbox Code Playgroud) 我正在python中完成这个任务,但我不确定我是否正确地将这些元素添加到列表中.所以基本上我假设创建一个create_list函数,它获取列表的大小并提示用户输入那么多值并将每个值存储到列表中.create_list函数应该返回这个新创建的列表.最后,main()函数应该提示用户输入的值的数量,将该值传递给create_list函数以设置列表,然后调用get_total函数来打印列表的总和.请告诉我我错过了什么或做错了什么.非常感谢你提前.
def main():
# create a list
myList = []
number_of_values = input('Please enter number of values: ')
# Display the total of the list elements.
print('the list is: ', create_list(number_of_values))
print('the total is ', get_total(myList))
# The get_total function accepts a list as an
# argument returns the total sum of the values in
# the list
def get_total(value_list):
total = 0
# calculate the total of the list elements
for num in value_list:
total += num
#Return the …Run Code Online (Sandbox Code Playgroud) 您好,我正在处理这个简单的表单,尝试使用 发送文件到我的 Nodejs 服务器FormData,但由于某种原因 Node 从未收到它。另外,我怎样才能让节点在页面上发回一条确认消息,说明已收到文件。我做错了什么或错过了什么?请帮忙。先感谢您。这是我的代码。
超文本标记语言
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript">
var fd = new FormData();
fd.append( 'file', input.files[0] );
$.ajax({
url: '/uploadfile',
data: fd,
processData: false,
contentType: false,
type: 'POST',
success: function(data){
alert(data);
}
});
</script>
</head>
<body>
<form enctype='multipart/form-data'>
<input type= "text" name = "theName"/>
<input type="file" id="file" name="file">
<input type="submit">
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
服务器(Node.js)
var express = require('express');
var router = express.Router();
/* GET users listing. */
router.get('/', function(req, res){
res.sendfile('./public/html/form-file.html');
}); …Run Code Online (Sandbox Code Playgroud) 我正在使用Ajax进行POST,而我的服务器正在获取数据.但是,我很难访问用户发送的值.简单来说,如何访问"user"(tom)的值?任何人都可以让我走上正轨.先感谢您.这是我的JsonResponse对象:
[2016-10-22 05:10:49] local.INFO: From Ajax: Illuminate\Http\JsonResponse Object
(
[data:protected] => {"user":"Tom","_token":"uRZJBVHH3worhjX4Ul6WlnJC1JYh3EVMNWob7Azr"}
[callback:protected] =>
[encodingOptions:protected] => 0
[headers] => Symfony\Component\HttpFoundation\ResponseHeaderBag Object
(
[computedCacheControl:protected] => Array
(
[no-cache] => 1
)
[cookies:protected] => Array
(
)
[headerNames:protected] => Array
(
[cache-control] => Cache-Control
[content-type] => Content-Type
)
[headers:protected] => Array
(
[cache-control] => Array
(
[0] => no-cache
)
[content-type] => Array
(
[0] => application/json
)
)
[cacheControl:protected] => Array
(
)
)
[content:protected] => {"user":"Tom","_token":"uRZJBVHH3worhjX4Ul6WlnJC1JYh3EVMNWob7Azr"}
[version:protected] => 1.0
[statusCode:protected] …Run Code Online (Sandbox Code Playgroud) 我只想使用PrimeNG从手风琴面板标题中删除箭头图标。有谁知道如何做到这一点?
代码:
<p-accordion>
<p-accordionTab header="Godfather I">
Content 1
</p-accordionTab>
<p-accordionTab header="Godfather II">
Content 2
</p-accordionTab>
<p-accordionTab header="Godfather III">
Content 3
</p-accordionTab>
Run Code Online (Sandbox Code Playgroud)
是否可以使用jQuery从pararaph中获取相同的字母数?所以让我说我有这个段落:
<div>like this printer</div>
Run Code Online (Sandbox Code Playgroud)
我想获得"i"的字符数,这意味着我应该得到3,因为有3个"我".我在考虑使用$(div:contains(i)),但现在确定如何实现它.有什么建议?非常感谢!
我正在研究这个程序,我需要验证字符串中的每个奇数索引是否都有字母"X".例如,如果我的字符串是:AXFXTX,那么我应该收到一条消息:"GOOD",如果不是,我应该收到一条消息:"BAD".任何人都可以告诉我我错过了什么.先谢谢你.
这是我的代码
import java.util.Random;
import java.util.Scanner;
public class Program {
public static void main(String[] args) {
Random rand = new Random();
Scanner scan = new Scanner(System.in);
int min = 1;
int max = 10;
int randomNum = rand.nextInt((max - min) + 1) + min;
System.out.println("Random number = " + randomNum);
System.out.print("Enter a word of " + randomNum + " characters:");
String myString = scan.nextLine();
while(myString.length() != randomNum){
System.out.print("Enter a word of " + randomNum + " characters:");
myString = scan.nextLine(); …Run Code Online (Sandbox Code Playgroud) 我正在尝试从 Groovy 中的 JSON 数组获取 ID 列表。我知道如何使用常规 FOR 循环获取 ID,但我想知道如何使用 every方法执行相同操作。我不知道如何实施。有人有什么主意吗?先感谢您。这是我的代码,使用常规 for 循环可以正常工作。不过我想用每种方法来做到这一点。
import groovy.json.*
def restresponse = '[{"id":5, "name":"Bob"},{"id":8, "name":"John"},{"id":12, "name":"Jim"},{"id":20, "name":"Sally"}]'
def json = new JsonSlurper().parseText(restresponse)
def myListOfIDs = []
for (int i = 0; i < json.size; i++) {
myListOfIDs.add(json[i].id) // getting all ID's for each SourceSystem
}
log.info(myListOfIDs) // This prints out all this IDs
Run Code Online (Sandbox Code Playgroud)