我创建了一个侧边栏菜单,但是在点击菜单项后我无法隐藏菜单.我按照https://blog.thecodecampus.de/angular-2-animate-creating-sliding-side-navigation/中的示例进行操作
我是否需要在(点击)html的每个超链接上调用toggleMenu?如果是,如何从另一个组件调用app.component.ts中的方法?
需要帮助...
我正在使用Angular 4和bootstrap 4.
这是我的代码:app.component.html:
<button (click)="toggleMenu()" class="hamburger">
<span>toggle menu</span>
</button>
<!-- <app-menu [@slideInOut]="menuState"></app-menu> -->
<navigation-component [@slideInOut]="menuState"> </navigation-component>
<div class="container-fluid">
<alert></alert>
<router-outlet></router-outlet>
</div>
Run Code Online (Sandbox Code Playgroud)
navigation.component.mobile.html:
<li><a routerLink="/home" routerLinkActive="active"> Home</a></li>
<li>
<a href="#submenu1" data-toggle="collapse">Alert</a>
<ul id="submenu1" class="list-unstyled collapse">
<li><a routerLink="/linesidemonitor" data-toggle="collapse" data-target=".navbar-collapse.show">IQS Alert</a></li>
</ul>
</li>
<li routerLinkActive="active" [hidden]="!authenticated()">
<a href="#submenu2" data-toggle="collapse">Configuration</a>
<ul id="submenu2" class="list-unstyled collapse">
<li><a routerLink="/contact" data-toggle="collapse" data-target=".navbar-collapse.show">Contacts</a></li>
<li><a routerLink="/department" data-toggle="collapse" data-target=".navbar-collapse.show">Departments</a></li>
<li><a routerLink="/notificationlevel">NotificationLevels</a></li>
<li><a routerLink="/recipient">Recipients</a></li>
</ul>
</li>
Run Code Online (Sandbox Code Playgroud)
app.component.ts:
@Component({
selector: 'app-root',
templateUrl: './' + (window.innerWidth > …
Run Code Online (Sandbox Code Playgroud) 当我尝试连接到另一个域中的 REST 服务时出现错误。我知道可以通过在java Rest服务中添加CORS来解决。但是可以通过改变 Angular 方面的一些东西来实现吗?
Access to 'http://someurl/RestWeb/getPerson' XMLHttpRequest at from origin 'http://localhost:4200' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values '*, *'
Run Code Online (Sandbox Code Playgroud)
我的休息服务:http://someurl/RestWeb/getPerson,我所有的休息服务网址如下:http://someurl/RestWeb/SOMETHING
我的 Angular 网址:http://someotherurl
在搜索不同的文章后,我已经尝试更改proxy.conf.json
和package.json
。下面是我的更改,但我仍然得到相同的结果。
代理.conf.json
{
"/RestWeb": {
"target": "http://someurl/",
"secure": false,
"changeOrigin": true // I tried with and without this. No luck
}
}
Run Code Online (Sandbox Code Playgroud)
包.json
"start": "ng serve --proxy-config proxy.conf.json",
Run Code Online (Sandbox Code Playgroud)
服务:
findAll(): Observable<Person[]> {
return this.httpClient.get<string[]>('http://someurl/RestWeb/getPerson');
}
Run Code Online (Sandbox Code Playgroud)
运行使用:
npm start
Run Code Online (Sandbox Code Playgroud)
作为临时对策,现在我正在使用 chrome 浏览器测试我的应用程序
chrome.exe --user-data-dir="C://Chrome dev …
Run Code Online (Sandbox Code Playgroud) 我正在为OpenJPA的问题而努力。
我有一个方法:
public void update() {
System.out.println("START: Update...");
updateEmployee(employee);
updateStudent(student);
System.out.println("END: Update...");
}
updateEmployee(employee) {
employeeDAO.update(employee);
}
updateStudent(student) {
studentDAO.update(student);
}
Run Code Online (Sandbox Code Playgroud)
但是,当我运行此命令时,我会收到如下日志:
开始:更新...
更新com.sk.entity.Employee设置...
更新com.sk.entity.Student设置...
结束:更新...
openjpa.jdbc.SQL-执行prepstmnt 2036496738 更新学生设置...
openjpa.jdbc.SQL-执行prepstmnt 2036496738 UPDATE EMPLOYEE SET ...
在这里我仍然没有得到:
为什么在我调用updateEmplyoee方法后不立即执行更新查询。您可以在我的日志语句“ END:更新...”之后看到打印了sql的日志。
为什么学生表首先被更新。按照方法调用,我首先要调用updateEmployee
如果您知道我所缺少的任何人,请给我答复。
我现在正在使用 Apache POI 从 Java 创建一个 excel,我需要在导出的 excel 中展开/折叠全部。请在展开之前和之后找到我想要的以下图像,以及到目前为止我尝试过的以下代码。(如果您正在尝试,它可能需要所需的 jar)。任何人都可以请帮忙。
代码:
package com.skumar.excel;
import java.io.FileOutputStream;
import java.util.Set;
import java.util.TreeSet;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Workbook;
public class ExcelGroupData {
public static void main(String[] args)
{
String excelFilename = null;
ExcelGroupData myExcel = new ExcelGroupData();
/* if (args.length < 1)
{
System.err.println("Usage: java "+ myExcel.getClass().getName()+
" Excel_Filename");
System.exit(1);
}
excelFilename = args[0].trim();*/
excelFilename = "C:\\aaa\\excel.xls";
myExcel.generateExcel(excelFilename);
}
public void …
Run Code Online (Sandbox Code Playgroud) 我有一个带有确认框的AlertService。我是通过我的服务打电话给我的。如果用户单击“是”,那么我想调用REST服务。但我收到此错误:
我相信,由于我是从alertService.confirm()内部调用的,而alertService没有声明http,因此我会收到此错误。但是我不确定解决此问题的适当方法。
ERROR TypeError: Cannot read property 'http' of undefined
at inspection.service.ts:91
at Object.siFn (alert.service.ts:53)
at Object.eval [as handleEvent] (AlertComponent.html:25)
at handleEvent (core.es5.js:11998)
at callWithDebugContext (core.es5.js:13467)
at Object.debugHandleEvent [as handleEvent] (core.es5.js:13055)
at dispatchEvent (core.es5.js:8614)
at core.es5.js:9228
at HTMLAnchorElement.<anonymous> (platform-browser.es5.js:2648)
at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
Run Code Online (Sandbox Code Playgroud)
检查组件
import {Component, OnInit, Input, ViewChild} from "@angular/core";
import {Headers, Http} from "@angular/http";
import {Router} from "@angular/router";
import {NgModel, FormGroup} from "@angular/forms";
sendMesage(inspection) {
this.inspectionService.sendMesage(inspection);
}
Run Code Online (Sandbox Code Playgroud)
检查服务
import {Headers, Http} from "@angular/http";
import {Observable} from 'rxjs/Observable';
import {Subject} …
Run Code Online (Sandbox Code Playgroud) 我试图在单击图像时显示隐藏我的导航栏。第一次点击它可以工作,之后就不行了。不知道出了什么问题。请问有什么帮助吗???
https://stackblitz.com/edit/responsive-menu-angular-material-flex-layout-cm87il
<img id="project-avatar" (click)="toggleNavbar()" width=20, height=20 style="position: relative;" alt="Show Hide Navigation Menu" src="/assets/img/slider_hide.png" />
<div>
<div class="showHideNavbar" [ngStyle]="displayNavbar == '1' ? {'visibility': 'visible'} : {'visibility': 'hidden'}">
<mat-toolbar color="primary" >
Run Code Online (Sandbox Code Playgroud)
displayNavbar: string;
ngOnInit() {
this.displayNavbar = '1';
}
toggleNavbar() {
if(this.displayNavbar == '0') {
this.displayNavbar = '1';
alert(this.displayNavbar);
} if(this.displayNavbar == '1') {
// alert("1 - Changing to 0");
this.displayNavbar = '0';
} else {
this.displayNavbar = '1';
}
}
Run Code Online (Sandbox Code Playgroud)
2)单击图标(位于左上角)时,工具栏应隐藏 - 这是第一次工作
3)再次单击该图标时,工具栏应再次显示 - 它不起作用 …
我正在使用Spring Boot,Maven和Eclipse开发Angular项目。我想使用“ ng serve”,因此不必每次都构建。因此,我试图使用“ ng serve”从Angular访问网页,并使用REST调用从spring boot获取数据。现在,由于我已经有很多REST调用,所以我不想转到每个文件并将URL更改为http:// localhost:8080 / api / inspection
我想将http:// localhost:8080添加到所有REST调用中。我尝试了以下代码,但仍在调用http:// localhost:4200 / api / inspection
创建的IqsInterceptor.ts:
import { Injectable, } from '@angular/core';
import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor} from '@angular/common/http';
import { Observable} from 'rxjs/Observable';
@Injectable()
export class IqsInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
const url = 'http://localhost:8080';
req = req.clone({
url: url + req.url
});
return next.handle(req);
}
}
Run Code Online (Sandbox Code Playgroud)
更新了app.module.ts:
import {BrowserModule} from '@angular/platform-browser';
import …
Run Code Online (Sandbox Code Playgroud) 是的,我确实搜索并找到了很多示例,但没有一个对我有用。我不确定我做错了什么。需要帮忙!
如果我放入<img>
标签,我可以看到图像,但当我放入background-image
. 但是当我检查元素时我可以看到二进制图像。
尝试在 stackblitz https://stackblitz.com/edit/display-image-from-rest-api-qpnspq?embed=1&file=src/app/app.component.ts 中做一个例子
HTML:
<!-- This works -->
<div class="row" style="max-width: 100%; margin-left: 1px;" >
<img id="dashboardImage" [src]='imageBlobDataUrl' height='500' width='500' />
</div>
<!-- This does NOT works -->
<div class="row" style="max-width: 100%; margin-left: 1px;" [style.background-image]="image"> </div>
Run Code Online (Sandbox Code Playgroud)
TS:
@Input() imageBlobDataUrl: any;
selectedImage: QiImage = new QiImage();
public header:SafeHtml;
public content:SafeHtml[];
public image:SafeStyle;
constructor(
private qiImageService: QiImageService,
private sanitizer: DomSanitizer,
private imageService: ImageService
) {}
populateImageDetails(lineId, bitmapFileName) {
this.imageService
.populateImageDetails(lineId, bitmapFileName)
.subscribe( (selectedImage …
Run Code Online (Sandbox Code Playgroud) 我需要获取所选下拉列表的值而不是文本.例如:IN为印度下拉.
<select id="country">
<option val="IN">India</option>
<option val="CN">China</option>
<option val="AU">Australia</option></select>
<div id ="get"></div>
Run Code Online (Sandbox Code Playgroud)
脚本:
$("#get").text($("#country").val());?
Run Code Online (Sandbox Code Playgroud)
请参考http://jsfiddle.net/yxMSK/3/
我在某个地方犯了一个愚蠢的错误但却无法找到它.Plz的帮助.
我试图从setTimeout()函数内部调用函数。我在下面尝试了所有方法,但还没有运气。我不确定这是Angular问题还是普通的javascript问题。如果我调用alert()函数,则它正常工作,但是当我调用函数时,它却无法正常工作。
抛出错误:this.getThreshold不是函数或不能红色属性'getThreshold'
component.ts
updateCount(inspection, rankName: string, rankPlusOrMinus: string)
{
inspection.rankName = rankName;
inspection.rankPlusOrMinus = rankPlusOrMinus;
this.inspectionService
.update(inspection).then(function(res) {
/* setTimeout(() => {
this.getThreshold(rankName, rankAcount);
});
*/
/*setTimeout(()=>{ //<<<--- using ()=> syntax
this.getThreshold();
},300);*/
/* setTimeout(function(){ // normal function
this.inspectionService.getThreshold();
}, 300) */
/* setTimeout(_=> {
//this.getThreshold();
this.inspectionService.getThreshold();
}, 300);*/
setTimeout(
function(){
this.getThreshold();
}
, 350);
})
.catch(function(rej) {
console.log(rej);
});
}
getThreshold() {
alert("123");
}
Run Code Online (Sandbox Code Playgroud)
服务
update(inspection: Inspection): Promise<Inspection> {
const url = '/api/inspection/updatecount/';
let rankName = inspection.rankName;
return this.http …
Run Code Online (Sandbox Code Playgroud) angular ×7
typescript ×6
apache-poi ×1
bootstrap-4 ×1
cors ×1
css ×1
excel ×1
execution ×1
java ×1
javascript ×1
jpa ×1
jquery ×1
openjpa ×1
pivot-table ×1
sanitize ×1