angular

Access javascript variable included in HTML header from typescript

我只是一个虾纸丫 提交于 2021-02-11 10:16:27
问题 I have a javascript file included in the <head></head> tags of my Angular 2 app. I would like to access a function in that javascript file from my typescript file, how should I do that? When I'm running the app, I can type var simplemde = new SimpleMDE() in the browser console to get my markdown editor working, but how can I do this in the constructor in my typescript file? 回答1: Just declare it at the top of your component or wherever you need it like so: declare var SimpleMDE: any; Then you

How to dynamically apply a tooltip to part of an element's dynamic text content in Angular?

会有一股神秘感。 提交于 2021-02-11 09:45:01
问题 So I have this json file containing a dictionary. definitions.json { "word": "Some definition.", "an expression": "Some other definition." } And I have components throughout my app that may be similar to this. my.component.ts @Component({ selector: 'my', template: ` <h1>{{ someTitleText }}</h1> <p>{{ someText }}</p> ` }) export class MyComponent { @Input() someTitleText: string; @Input() myText: string; } I want to display a tooltip when the user will hover over a word that is present in the

Creating a dataservice to communicate between c# api and frontend (angular)

我只是一个虾纸丫 提交于 2021-02-11 09:02:03
问题 I need some help with this. I'm supposed to create a plugin for a webpage in angular that communicates with an API written in C# which is already in a .dll. What is the best approach to this? I already created a data.service.ts with the following code to get data from the api: import { Injectable, ValueProvider } from '@angular/core'; @Injectable({ providedIn: 'root' }) export class DataService { edge : any = require('edge'); constructor() { } getData(type: String, method: String) { var data

API polling and timeout

非 Y 不嫁゛ 提交于 2021-02-11 08:52:06
问题 I have a polling use-case where: I want to call an API that, based on business logic, returns numbers(1-10) or error (network issue/ exception in API etc..) instantly (1.5-2 sec). If the API returns an error (network issue/ exception in API etc..) then I want to unsubscribe the polling and display error. If the API returns success, I want to check the return value and un-subscribe(if the return value is 5) or keep the polling going. I want to call API every 5 sec. I want to keep the max time

Angular app running on azure app service not receive .AspNetCore.Antiforgery cookie sent by .net core web api app on azure

荒凉一梦 提交于 2021-02-11 08:00:36
问题 I have angular 5 app and .net core 2.0 web api app hosted on azure as app services. Apps have two urls as below. angularclient.azurewebsites.net serviceapi.azurewebsites.net The issue I am facing is angular app not receiving .AspNetCore.Antiforgery cookie that is sent by serviceapi. Http post request generated by angular app has "withCredentials: true" header. I have defined cors policy in service API as below. app.UseCors(builder => builder.WithOrigins("angularclient.azurewebsites.net")

How to set background image in div-element in Angular Material app?

若如初见. 提交于 2021-02-11 07:43:57
问题 I know this has been asked, but none of the solutions work. I have following html and I can get the image displayed if I use the commented img-element <img src="assets/utgmap.jpg"> and comment away the following div-element. However I would like to have background image for the div instead and it's not working. CSS definition is in the end of the file and there's no 404 error for the image so it can be fetched but is is not displayed. HTML: <mat-sidenav-container class="sidenav-container">

ngClass not working in my Angular Project

流过昼夜 提交于 2021-02-11 07:17:23
问题 I'm trying to make a form with validation, and I am using the following interface to define FieldError . export interface FieldError { errorAt: string; errorMessage: string; } In my component.html I am using [ngClass] to check if the FieldError.errorAt === 'first_name' I want to use text-danger and if not I want to use text-muted . It looks like following <div class="form-group text-left"> <label [ngClass]="{'text-danger':FieldError.errorAt==='first_name','text-muted':FieldError.errorAt!==

Can I change the concatenation character of the String-Array regarding JHipsters 'jhiTranslate'?

前提是你 提交于 2021-02-11 07:15:35
问题 If I use a string array for translation in e.g. i18n/en/home.json like "primaryIntroduction": { "p1": [ "Then Jenkins triggers a task to connect to the docker-server", " and calls some docker- and docker-compose commands to pull the new image", " and rebuilds and restarts the docker-container." ] } jhipster concatenates the <p> on the english page like: Then Jenkins triggers a task to connect to the docker-server, and calls some docker- and docker-compose commands to pull the new image, and

Can I change the concatenation character of the String-Array regarding JHipsters 'jhiTranslate'?

我怕爱的太早我们不能终老 提交于 2021-02-11 07:10:26
问题 If I use a string array for translation in e.g. i18n/en/home.json like "primaryIntroduction": { "p1": [ "Then Jenkins triggers a task to connect to the docker-server", " and calls some docker- and docker-compose commands to pull the new image", " and rebuilds and restarts the docker-container." ] } jhipster concatenates the <p> on the english page like: Then Jenkins triggers a task to connect to the docker-server, and calls some docker- and docker-compose commands to pull the new image, and

Can I change the concatenation character of the String-Array regarding JHipsters 'jhiTranslate'?

那年仲夏 提交于 2021-02-11 07:09:09
问题 If I use a string array for translation in e.g. i18n/en/home.json like "primaryIntroduction": { "p1": [ "Then Jenkins triggers a task to connect to the docker-server", " and calls some docker- and docker-compose commands to pull the new image", " and rebuilds and restarts the docker-container." ] } jhipster concatenates the <p> on the english page like: Then Jenkins triggers a task to connect to the docker-server, and calls some docker- and docker-compose commands to pull the new image, and