frontend

How to instantiate In angular2 ngx-bootstrap modal when the modal is open

柔情痞子 提交于 2019-12-25 12:11:51
问题 This is my parent component template fragment: <button type="button" (click)="addModal.show();">Add</button> <add-modal #addModal></add-modal> And this is my modal component: Component({ selector: 'card-add-modal', template: ` <div *ngIf="isShowModal" bsModal #addModal="bs-modal" [config]="{show: true, backdrop: 'static'}" (onHidden)="onHidden()" class="modal fade"> <!-- header... --> <div class="modal-body"> <input type="text" name="name" id="name" [(ngModel)]="model.test"> </div> <!--

(React.js )Initial state generated randomly. How to prevent it from regenerate each time I handle an event?

喜欢而已 提交于 2019-12-25 09:18:46
问题 I am building a game that players can attack each other by turn. So first I set the name , job manually and generate life , damage , magic randomly in componentWillMount() . I hope that every time I submit the attack form, certain amount of life with be reduced from the attacked person. But now every time I submit, the whole state is regenerated(with all kinds of bugs). Can I do something to solve it? app.js : https://ghostbin.com/paste/ype2y attack.js : https://ghostbin.com/paste/wzm3m 回答1:

How to change the keys in one object with javascript?

痞子三分冷 提交于 2019-12-25 08:57:23
问题 I have: var myAbc = { 0: true, 1: false, 2: true }; and i want to change de keys like: var myAbc = { key1: true, key2: false, key3: true }; i have already tried this: for (var key in array) { key = value; } but did not change the key of the array out side of the for, any help? 回答1: If you can use es6, you can do this in one line: var myAbc = { 0: true, 1: false, 2: true }; var renamed = Object.keys(myAbc).reduce((p, c) => { p[`key${Number(c)+1}`] = myAbc[c]; return p; }, {}) console.log

How do I access certain column in bootstrap grid system?

旧时模样 提交于 2019-12-25 07:44:22
问题 In the bootstrap grid system, there are 12 columns and col - *- * class is used to group together certain number of columns. But when I want to use the first 3 columns and then just the last column how do I do that, that is, how can I use certain columns and not others in a single row class? Like when I make a page header, I give the title on the left hand side and certain other text on the right side of the header, I assume I can use the grid system here effectively, given that I can access

How do i find the last <li></li> in every <ul></ul> (Front-end, html, css , jquery)

落花浮王杯 提交于 2019-12-25 06:47:33
问题 I have a menu with their own submenus too. Problem: When the page is loaded, the website emits a letter S at the end of every submenu . How can i remove that letter S at the end of every submenu via JQuery or CSS? This is the current markup when I copy html node in firebug: <nav class="shopMenuHover"> <div id="bx_incl_area_5_1"> <ul> <li class=""><a href="#" class="firstLevel"><font><font>Main Menu 1</font></font></a> <div class="shopSubmenuHover" style=""><h2><a href="#"><font><font>Sub Menu

Front-end and back-end terminology

ぐ巨炮叔叔 提交于 2019-12-25 05:04:18
问题 While designing a Web Application in ASP.Net, I usually split the project in 2 parts, the back-end (the admin part) and the front-end (the visitors/SEO part). Let's say that my visitors can login on the website and will do a lot of tasks, like fill profile, send messages, etc. That part (authenticated user) looks for me a differente "layer" between Front-end and Back-end, and is somewhat hard define if is front-end (why visitors/users will handle it, but no admins) or if it is back-end (why

How to process raw jpeg data into a file in javascript

ⅰ亾dé卋堺 提交于 2019-12-25 01:32:42
问题 I'm trying to create a jpeg file from raw data in javascript I've been using the google file picker api to allow users to select their images from drive and import into my application, but when I make the request to download the image google responds with raw data that looks like this: Google's response I have tried placing that data into a blob with: var blob = new Blob([res.text], {type: 'image/jpeg'}) I have also tried placing the data into a file. var file = new File([res.text], 'image

How to base64 encode binary image in JS for browser showing

夙愿已清 提交于 2019-12-25 01:17:19
问题 We have a problem with showing in browser (actually Chrome) binary images receiving from REST backend API. The backend REST endpoint defined in Java like this @GetMapping(path = "/images/{imageId:\\d+}/data", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) public @ResponseBody byte[] getImageData(@PathVariable long imageId) { return ... skipped ... } On the frontend we do these steps: request image data via fetch JS method call async function getImage(id) { return await fetch(`${URL}

Sorting Angular table without using Materials, just sort method?

别来无恙 提交于 2019-12-25 01:02:51
问题 table.component.html When I click on the Header, the function have to sort ASC/DESC all the column. <table> <tr> <th *ngFor="let col of columns" (click)="sortTable(col)">{{col}}</th> </tr> <tr *ngFor="let user of users"> <td *ngFor="let col of columns">{{user[col]}}</td> </tr> </table> table.component.ts The method sortTable(param) work just ASC and I can't click on the same Header again for the DESC so it remain the same until I click on another Header. export class DynamicTableComponent

How to modify React component to use hooks?

扶醉桌前 提交于 2019-12-24 22:42:51
问题 Below is a login component without hooks. This component has two input fields and a submit button. How can we modify this component to use hooks and convert this component into a functional component that can use states? import React from 'react'; import { userService } from '../services/user.services'; class Login extends React.Component { constructor(props) { super(props); this.state = { username: '', password: '', submitted: false, loading: false, error: '' } this.handleChange = this