我在一个项目中使用带有 Angular 6 的引导表,并且我能够使用以下代码创建垂直滚动表体:
<table class="table table-striped table-bordered" style="margin-bottom: 0">
<thead> <!-- Column names -->
<tr>
<th scope="col">#</th>
<th scope="col">Col 1</th>
<th scope="col">Col 2</th>
<th scope="col">Col 3</th>
...
<th scope="col">Col N</th>
</tr>
</thead>
<tbody> <!-- Data -->
<tr>
<th scope="row">1</th>
<td>AAAAA</td>
<td>BBBBB</td>
<td>CCCCC</td>
...
<td>DDDDD</td>
</tr>
<tr>
<th scope="row">2</th>
<td>AAAAA</td>
<td>BBBBB</td>
<td>CCCCC</td>
...
<td>DDDDD</td>
</tr>
...
<tr>
<th scope="row">n</th>
<td>AAAAA</td>
<td>BBBBB</td>
<td>CCCCC</td>
...
<td>DDDDD</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
和CSS:
tbody {
display:block;
max-height:500px;
overflow-y:auto;
}
thead, tbody tr {
display:table;
width:100%; …Run Code Online (Sandbox Code Playgroud) 我正在开发一个项目,需要将音频流发送到 Node.js 服务器。我可以使用此功能捕获麦克风声音:
function micCapture(){
'use strict';
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
var constraints = {
audio: true,
video: false
};
var video = document.querySelector('video');
function successCallback(stream) {
window.stream = stream; // stream available to console
if (window.URL) {
video.src = window.webkitURL.createObjectURL(stream);
} else {
video.src = stream;
}
//Send audio stream
//server.send(stream);
}
function errorCallback(error) {
console.log('navigator.getUserMedia error: ', error);
}
navigator.getUserMedia(constraints, successCallback, errorCallback);
}
Run Code Online (Sandbox Code Playgroud)
如您所见,我能够捕获音频并在网站上播放。
现在我想将该音频流发送到 Node.js 服务器,并将其发送回其他客户端。就像语音聊天一样,但我不想使用 WebRTC,因为我需要服务器中的流。我怎样才能实现这个目标?我可以使用 socket.io-stream 来做到这一点吗?在我看到的示例中,他们录制了音频并发送了文件,但我需要“实时”音频。
我按照这个答案为我的 Angular 6 + Material 应用程序创建了一个路由动画,但我将动画更改为这个:
const fade = [
// route 'enter' transition
transition(':enter', [
// css styles at start of transition
style({ opacity: 0 }),
// animation and styles at end of transition
animate('.3s', style({ opacity: 1 }))
])
];
Run Code Online (Sandbox Code Playgroud)
这是中的代码app.component.ts:
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
animations: [
trigger('routerAnimations', [
transition('* => *', fade)
])
]
})
export class AppComponent {
prepareRouteTransition(outlet) {
const animation = outlet.activatedRouteData['animation'] || {};
return animation['value'] || …Run Code Online (Sandbox Code Playgroud) 我正在使用 JavaScript 库DetectRTC来检测浏览器是否可以使用麦克风和其他东西。
if(DetectRTC.isWebsiteHasMicrophonePermissions){
//Is ok
}else{
//Can't use microphone
}
Run Code Online (Sandbox Code Playgroud)
该网站有使用麦克风的权限,但DetectRTC.isWebsiteHasMicrophonePermissions仍然是假的。所以我试图在控制台上打印对象,我得到它isWebsiteHasMicrophonePermissions被设置为 true。但是当我单独打印变量时,它再次变为 false。
console.log(DetectRTC); //isWebsiteHasMicrophonePermissions: true
console.log(DetectRTC.isWebsiteHasMicrophonePermissions) //false
Run Code Online (Sandbox Code Playgroud)
这是错误还是什么?我该如何解决?
我正在建立一个使用Angular Material Autocomplete模块的表单。我从服务器加载选项,并使用输入过滤它们。效果很好,现在我想添加一个“清除”图标,以在需要时清除该字段。
clear选项将清除该字段,但不会再次显示自动完成选项。当我手动删除带有退格但不带有图标的输入内容时,它将显示它们。
为了“清除”该字段,我使用以下代码:
clear(control: string): void {
this.form.get(control).setValue('');
}
Run Code Online (Sandbox Code Playgroud)
我从一个mat-icon组件中调用它:
<mat-form-field>
<input matInput type="text" ... >
<mat-icon matSuffix (click)="clear(fieldName)" ...>
clear</mat-icon>
</mat-form-field>
<mat-autocomplete> ... </mat-autocomplete>
Run Code Online (Sandbox Code Playgroud)
其中fieldName(字符串)是我要清除的控件的名称。
这就是我过滤自动填充选项的方式:
this.filter = this.form.get(field).valueChanges.pipe(
startWith(''), // Don't even know what this does...
map(value => this.options.filter(option => option.name.toLowerCase().includes(value.toString().toLowerCase())))
);
Run Code Online (Sandbox Code Playgroud)
我怀疑方法setValue('')内部可能有错误clear()。或者也许是我正在使用的过滤方法。
这是StackBlitz中的完整示例:
https://stackblitz.com/edit/angular-autocomplete-clear9zzmw2
//请原谅我的英语
我想在我的'client'表中选择最大的id(它有383个客户端,这意味着383它是最大的id),但当我进行查询时它返回'99'.
$query = "SELECT MAX(id) FROM clients";
Run Code Online (Sandbox Code Playgroud)
我不知道该怎么办.我的目标是为最新的id添加1以为新客户端创建新的id.
我有一个jquery脚本,每当我在输入中输入内容时,都会选中一个复选框.
所以,当我删除该输入中的所有数据时,我想取消选中该复选框,使用退格键,并执行其他操作.
编辑:
我有多个输入和复选框.有些人问我代码,所以这就是它(它们是多个复选框和像这样的表中的输入,都有不同的名称):
<tr><td class="chk">
<input type="checkbox" name="has_mic" autocomplete="off">
Micrófono</td>
<td class="txt"><input type="text" class="nsize upper" name="mic_obs"></td></tr>
Run Code Online (Sandbox Code Playgroud)
和剧本:
$("input[type=text]").keydown(
function(){
$(this).parent('.txt').siblings('.chk').find('input[type=checkbox]').prop('checked', true);
});
Run Code Online (Sandbox Code Playgroud)
因此,使用此代码,每当我输入输入时,都会检查相同<tr>中的复选框.我想要做的是,当我删除所有我输入的内容时,复选框将被取消选中并执行其他一些功能.
我需要用来file_get_contents()获取文件(file.php)中html页面(content.html)的内容,该文件位于如下目录中:
/content
- content.html
/functions
- file.php
Run Code Online (Sandbox Code Playgroud)
所以我尝试使用file_get_contents('../content/content.html')来获取 html 内容,但出现此错误:
failed to open stream: No such file or directory
Run Code Online (Sandbox Code Playgroud)
我想我可能使用了错误的路径。我能做些什么?