I want when i click new component button and add name,description,select type and add new attribute like default value and type, all information to be saved and new button to appear in drag and drop section. Please help me how to do it.
html and ts:
html:
<button
tuiButton
type="button"
size="m"
class="tui-space_right-3 tui-space_bottom-3"
(click)="showDialog()"
>
Neue Komponente
</button>
<ng-template
let-observer
[tuiDialogOptions]="{label: 'Neue Komponente', size: 's'}"
[(tuiDialog)]="open"
>
<form action="http://localhost:8080/komponente/save"
method = "POST"
[formGroup]="exampleForm"
(ngSubmit)="submitComponent(); observer.complete()"
>
<p></p>
<tui-input
tuiAutoFocus
formControlName="nameOfComponent"
id="nameInput"
>
Name
</tui-input>
<tui-input
tuiAutoFocus
formControlName="description"
>
Beschreibung
</tui-input>
<tui-select
#select
class="b-form"
[(ngModel)]="chosenComponent"
>Komponententyp
<tui-data-list *tuiDataList>
<tui-opt-group label="">
<button
*ngFor="let component of componentTypes"
tuiOption
[value]="component"
>
{{ component }}
</button>
</tui-opt-group>
</tui-data-list>
</tui-select>
<button
tuiButton
type="button"
size="m"
appearance="secondary"
class="tui-space_right-3 tui-space_bottom-3"
(click)="addNewAttributeButtonClick()"
>
Neues Attribut
</button>
<form [formGroup]="DragAndDropForm" (ngSubmit)="onSubmit()" class="form-horisontal"></form>
<div class="form-group" [hidden]="IsHidden">
<label class="col-md-8 control-label" for="defaultValue">
Default-Wert
</label>
<div class="col-md-8">
<input id="defaultValue" formControlName="defaultValue" type="number" class="form-contol">
</div>
</div>
<label class="col-md-8 control-label"></label>
<div class="col-md-8" [hidden]="IsHidden">
<label class="radio-inline" for="type">
Typ:
</label>
<label class="radio-inline">
<input id="radiobutton" type="radio" value="option1"
name="radiobutton">int
</label>
<label class="radio-inline">
<input id="radiobutton" type="radio" value="option2"
name="radiobutton">float
</label>
</div>
<p>
<button
tuiButton
type="submit"
>
Speichern
</button>
</p>
</form>
</ng-template>
<tui-accordion class="container" cdkDropList>
<tui-accordion-item>
Einspeiser
<ng-template tuiAccordionItemContent>
<div class="kraftwerk-box" cdkDrag>
<svg xmlns="http://www.w3.org/2000/svg" width="4em" height="4em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="#85b6ff" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M3 21h18M5 21V9l5 4V9l5 4h4"/><path d="M19 21v-8l-1.436-9.574A.5.5 0 0 0 17.069 3h-1.145a.5.5 0 0 0-.494.418L14 12m-5 5h1m4 0h1"/></g></svg>
</div>
<div #content>
Kraftwerk
</div>
<div class="kraftwerk-box" cdkDrag>
<svg xmlns="http://www.w3.org/2000/svg" width="4em" height="4em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="#85b6ff" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M9 16v-5a2 2 0 1 0-4 0m10 5v-5a2 2 0 1 1 4 0"/><path d="M12 16V6a3 3 0 0 1 6 0M6 6a3 3 0 0 1 6 0M3 16h18v2a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3v-2z"/></g></svg>
</div>
<div #content>
Wasserquelle
</div>
<div class="kraftwerk-box" cdkDrag>
<svg xmlns="http://www.w3.org/2000/svg" width="4em" height="4em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path fill="#85b6ff" d="m2.475 19.6l1.2-6q.125-.7.688-1.15Q4.925 12 5.65 12h12.7q.725 0 1.288.45q.562.45.687 1.15l1.2 6q.2.95-.412 1.675Q20.5 22 19.55 22H4.45q-.95 0-1.562-.725q-.613-.725-.413-1.675ZM6 3q0 .425-.287.712Q5.425 4 5 4H4q-.425 0-.712-.288Q3 3.425 3 3t.288-.713Q3.575 2 4 2h1q.425 0 .713.287Q6 2.575 6 3ZM4.45 20H11v-2H4.85l-.4 2ZM7.525 6.5q.3.3.3.713q0 .412-.3.712l-.7.7q-.275.275-.687.275q-.413 0-.713-.275q-.3-.3-.3-.713q0-.412.3-.712l.7-.7q.275-.275.687-.275q.413 0 .713.275ZM5.25 16H11v-2H5.65ZM12 7Q9.925 7 8.463 5.537Q7 4.075 7 2h2q0 1.25.875 2.125T12 5q1.25 0 2.125-.875T15 2h2q0 2.075-1.462 3.537Q14.075 7 12 7Zm0-5Zm0 6q.425 0 .713.287Q13 8.575 13 9v1q0 .425-.287.712Q12.425 11 12 11t-.712-.288Q11 10.425 11 10V9q0-.425.288-.713Q11.575 8 12 8Zm1 12h6.55l-.4-2H13Zm0-4h5.75l-.4-2H13Zm3.475-9.5q.275-.275.7-.275q.425 0 .7.275l.7.7q.3.3.313.7q.012.4-.288.7q-.3.3-.712.3q-.413 0-.713-.3l-.7-.7q-.275-.3-.287-.7q-.013-.4.287-.7ZM21 3q0 .425-.288.712Q20.425 4 20 4h-1q-.425 0-.712-.288Q18 3.425 18 3t.288-.713Q18.575 2 19 2h1q.425 0 .712.287Q21 2.575 21 3Z"/></svg>
</div>
<div #content>
Solaranlage
</div>
</ng-template>
</tui-accordion-item>
<tui-accordion-item>
Versorgung
<ng-template tuiAccordionItemContent>
<div class="kraftwerk-box" cdkDrag>
<svg xmlns="http://www.w3.org/2000/svg" width="4em" height="4em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="#85b6ff" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M3 21h18M5 21V9l5 4V9l5 4h4"/><path d="M19 21v-8l-1.436-9.574A.5.5 0 0 0 17.069 3h-1.145a.5.5 0 0 0-.494.418L14 12m-5 5h1m4 0h1"/></g></svg>
</div>
<div #content>
Kraftwerk
</div>
</ng-template>
</tui-accordion-item>
<tui-accordion-item>
Verträge
<ng-template tuiAccordionItemContent>
<div class="kraftwerk-box" cdkDrag>
<svg style="color: rgb(133, 182, 255);" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M292.7 342.3C289.7 345.3 288 349.4 288 353.7V416h62.34c4.264 0 8.35-1.703 11.35-4.727l156.9-158l-67.88-67.88L292.7 342.3zM568.5 167.4L536.6 135.5c-9.875-10-26-10-36 0l-27.25 27.25l67.88 67.88l27.25-27.25C578.5 193.4 578.5 177.3 568.5 167.4zM256 0v128h128L256 0zM256 448c-16.07-.2852-30.62-9.359-37.88-23.88c-2.875-5.875-8-6.5-10.12-6.5s-7.25 .625-10 6.125l-7.749 15.38C187.6 444.6 181.1 448 176 448H174.9c-6.5-.5-12-4.75-14-11L144 386.6L133.4 418.5C127.5 436.1 111 448 92.45 448H80C71.13 448 64 440.9 64 432S71.13 416 80 416h12.4c4.875 0 9.102-3.125 10.6-7.625l18.25-54.63C124.5 343.9 133.6 337.3 144 337.3s19.5 6.625 22.75 16.5l13.88 41.63c19.75-16.25 54.13-9.75 66 14.12C248.5 413.2 252.2 415.6 256 415.9V347c0-8.523 3.402-16.7 9.451-22.71L384 206.5V160H256c-17.67 0-32-14.33-32-32L224 0H48C21.49 0 0 21.49 0 48v416C0 490.5 21.49 512 48 512h288c26.51 0 48-21.49 48-48V448H256z" fill="#85b6ff"></path></svg>
</div>
<div #content>
Kaufvertrag
</div>
</ng-template>
</tui-accordion-item>
<tui-accordion-item>
Märkte
<ng-template tuiAccordionItemContent>
<div class="kraftwerk-box" cdkDrag>
Kraftwerk
</div>
</ng-template>
</tui-accordion-item>
<tui-accordion-item>
Speicher
<ng-template tuiAccordionItemContent>
<div class="kraftwerk-box" cdkDrag>
Kraftwerk
</div>
</ng-template>
</tui-accordion-item>
<tui-accordion-item>
Umwandler
<ng-template tuiAccordionItemContent>
<div class="kraftwerk-box" cdkDrag>
Kraftwerk
</div>
</ng-template>
</tui-accordion-item>
<tui-accordion-item>
Knoten/Bilanzen
<ng-template tuiAccordionItemContent>
<div class="kraftwerk-box" cdkDrag>
Kraftwerk
</div>
</ng-template>
</tui-accordion-item>
<tui-accordion-item>
Container
<ng-template tuiAccordionItemContent>
<div class="kraftwerk-box" cdkDrag>
Kraftwerk
</div>
</ng-template>
</tui-accordion-item>
</tui-accordion>
ts:
import { WorkspaceComponent } from './../workspace/workspace.component';
import { Component, OnInit } from '#angular/core';
import {DragDropModule} from '#angular/cdk/drag-drop';
import {ChangeDetectionStrategy, Inject} from '#angular/core';
import { ApiService } from '../services/api.service';
import {TuiDialogService} from '#taiga-ui/core';
import {FormArray, Validators} from '#angular/forms';
import { TabService } from '../services/tab.service';
import { FormGroup, FormControl } from '#angular/forms';
#Component({
selector: 'app-drag-and-drop',
templateUrl: './drag-and-drop.component.html',
styleUrls: ['./drag-and-drop.component.css']
})
export class DragAndDropComponent implements OnInit {
fb: any;
profileForm: any;
DragAndDropForm: FormGroup
constructor( #Inject(TuiDialogService) private readonly dialogService: TuiDialogService,
#Inject(ApiService) public apiService: ApiService,) { }
onSubmit(): void {
console.log(this.DragAndDropForm.value);
}
apps =
[
{
id: 1,
name: "Instagram"
},
{
id: 2,
name: "Facebook"
}
];
selectedApps = [];
// allowDrop(event) {
// event.preventDefault();
// }
// drag(event, appID: number) {
// event.dataTransfer.setData("dragApp", appID);
// return true;
// }
// drop(event) {
// const itemIndex = event.dataTransfer.getData("dragApp") - 1;
// this.selectedApps.push(this.apps[itemIndex]);
// console.log(this.selectedApps);
// }
// showDialog(): void {
// this.dialogService
// .open(`This is a plain string dialog`, {label: `Heading`, size: `s`})
// .subscribe();
// }
showDialogWithCustomButton(): void {
this.dialogService
.open(`Good, Anakin, Good!`, {
label: `Star wars. Episode III`,
size: `s`,
data: {button: `Do it!`},
})
.subscribe();
}
exampleForm = new FormGroup({
nameOfComponent: new FormControl(``),
description: new FormControl(''),
});
testForm = new FormGroup({
testValue: new FormControl(),
});
componentTypes = ['Einspeiser', 'Versorgung' ,'Vertrag', 'Markt', 'Speicher', 'Umwandler', 'Knoten/Bilanz', 'Container'];
chosenComponent = this.componentTypes[0];
open = false;
showDialog(): void {
this.open = true;
}
submitComponent(): void{
this.apiService.postComponent("document.getElementById('nameInput').value", "desc", "http://www.w3.org/2000/svg").subscribe((result)=>{console.warn(result)});
console.log(this.apiService.updateComponents());
}
ngOnInit() {
this.DragAndDropForm = new FormGroup({
fullName: new FormControl(),
// Create NewAttribute form group
NewAttribute: new FormGroup({
NewAttributeName: new FormControl(),
type: new FormControl()
})
});
}
IsHidden = true;
addNewAttributeButtonClick() {
this.IsHidden = !this.IsHidden;
}
addNewAttributeFormGroup(): FormGroup{
return this.fb.group({
defaultValue:['', Validators.required],
type:['', Validators.required]
});
}
}
Related
How to click on an element if all id's are random?
Unique - only text with description.
This is a list that contains various items that you can click with the mouse. I can't figure out how to make this click, for example, on an element containing the text "Some Unique Text 3"
<section class="css-1kyhqub">
<ul data-testid="categories-list" data-cy="categories-list" class="css-jfja6s">
<li data-cy="cy-im-parent" class="css-xedlmo">
<div class="css-17fti8"><span>
<p class="css-1jek2ew-Text eu5v0x0">Some Unique Text 1</p></span>
<span font-size="p4" class="css-my4n3k"></span>
</div>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="1em" height="1em" class="css-1mougrc">
</svg></li><li data-cy="cy-im-parent" class="css-xedlmo">
<div class="css-17fti8"><span><p class="css-1jek2ew-Text eu5v0x0">Some Unique Text 2</p></span>
<span font-size="p4" class="css-my4n3k"></span></div>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="1em" height="1em" class="css-1mougrc">
</svg></li>
<li data-cy="cy-im-child" data-testid="nested-category-item" class="css-12lzvy8">
<div class="css-19rredd">
<section class="css-u2ayx9">
<p class="css-1jek2ew-Text eu5v0x0">Some Unique Text 3</p>
</section>
<span font-size="p4" class="css-6zq905"></span></div></li>
<li data-cy="cy-im-parent" class="css-xedlmo">
<div class="css-17fti8"><span><p class="css-1jek2ew-Text eu5v0x0">Some Unique Text 4</p></span>
<span font-size="p4" class="css-my4n3k"></span></div><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="1em" height="1em" class="css-1mougrc">
</li><li data-cy="cy-im-child" data-testid="nested-category-item" class="css-12lzvy8">
<div class="css-19rredd">
<section class="css-u2ayx9">
<p class="css-1jek2ew-Text eu5v0x0">Some Unique Text 5</p>
</section>
<span font-size="p4" class="css-6zq905"></span></div></li></ul>
</section>
Any idea?
You can try this if you only want to click on one paragraph element containing specific text.
await page.evaluate(() => {
const elements = [...document.querySelectorAll('p')];
const targetElement = elements.find(e => e.innerText == 'Some Unique Text 3');
if (targetElement) targetElement.click();
});
Or if you want to click on multiple paragraph elements containing specific text try this.
await page.evaluate(() => {
Array.from(document.querySelectorAll('p')).filter(p => {
return p.innerText == 'Some Unique Text 3'
}).forEach(element => {
if (element) element.click();
});
});
I need to add a exit button to the top left corner of the modal, also I would like for the modal to disappear after the link has been copied. How would i go about doing this ?
<div>
<svg xmlns="http://www.w3.org/2000/svg" class="h-10 w-100" viewBox="21 21" fill="currentColor">
<path fill-rule="evenodd" d="M12.586 4.586a2 2 0 112.828 2.828l-3 3a2 2 0 01-2.828 0 1 1 0 00-1.414 1.414 4 4 0 005.656 0l3-3a4 4 0 00-5.656-5.656l-1.5 1.5a1 1 0 101.414 1.414l1.5-1.5zm-5 5a2 2 0 012.828 0 1 1 0 101.414-1.414 4 4 0 00-5.656 0l-3 3a4 4 0 105.656 5.656l1.5-1.5a1 1 0 10-1.414-1.414l-1.5 1.5a2 2 0 11-2.828-2.828l3-3z" clip-rule="evenodd" />
<text x='35' y='18' style='fill:#444444' class='text-2xl'>Share Link</text>
</svg>
<br />
<div style="display: flex; flex-direction: row; justify-content: space-between;">
<h1 class="text-left" id='text' style='user-select: all'><%= #vacancy.slug %>
<h2 class="text-right" id='text' style='user-select: all'>
<button onclick= "Copy(document.querySelector('#text').innerText)('#closemodal').click(function() {$('#modalwindow').modal('hide');});">
<svg class="align:right w-30 h-9" fill="none" stroke="currentColor" viewBox="0 0 25 25" xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7v8a2 2 0 002 2h6M8 7V5a2 2 0 012-2h4.586a1 1 0 01.707.293l4.414 4.414a1 1 0 01.293.707V15a2 2 0 01-2 2h-2M8 7H6a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2v-2"></path>
</svg>
</button>
</h2>
</h1>
</div>
</div>
<div class="text-center md:text-right mt-4 md:flex md:justify-end"></div>
<script src="//cdn.jsdelivr.net/npm/sweetalert2#11"></script>
<script type='text/javascript'>
function Copy(text) {
var elem = document.createElement('textarea');
elem.value = text;
document.body.appendChild(elem);
elem.select();
document.execCommand('copy');
document.body.removeChild(elem);
Swal.fire({
position: 'center',
icon: 'success',
showConfirmButton: false,
timer: 600
})
}
</script>
</div>
I looked at the site for the library you're using, SweetAlert2 and here is what I found...
To add a close button, add showCloseButton: true to the object passed to Swal.fire()
https://sweetalert2.github.io/#configuration
To close the modal call Swal.close()
https://sweetalert2.github.io/#methods
I want to pause the VIDEO when I slide by dragging or using slide next, prev buttons.
It doesn't matter which slider. it can be useful-swiper or owl-carousel
I'm using ngx-useful-swiper as my Carousel.
I can use ngx-owl-carousel-o instead, But if it worked with anyone
My HTML
<swiper [config]="heroSlider" #usefulSwiper>
<div class="swiper-wrapper">
<div class="swiper-slide text-center" *ngFor="let item of sections.about_video; index as i">
<video
poster="{{ fileUrl + item.thumbnail }}"
playsinline
autoplay="false"
muted
controls="false"
onloadedmetadata="this.muted = true"
src="{{ fileUrl + item.video }}"
id="video"
#video
></video>
</div>
</div>
<button class="btn p-0 btn-prev" (click)="previousSlide()">
<svg
version="1.1"
id="Layer_1"
x="0px"
y="0px"
viewBox="0 0 26 43"
style="enable-background: new 0 0 26 43"
xml:space="preserve"
>
<path
id="Path_3540"
class="st0"
d="M21.5,43c2.5,0,4.5-2,4.5-4.5c0-1.2-0.5-2.4-1.3-3.2L10.9,21.5L24.7,7.7
c1.7-1.8,1.7-4.7-0.1-6.4c-1.8-1.7-4.5-1.7-6.3,0l-16.9,17c-1.8,1.8-1.8,4.6,0,6.4l16.9,17C19.1,42.5,20.3,43,21.5,43z"
/>
</svg>
</button>
<button class="btn p-0 btn-next" (click)="nextSlide()">
<svg
class="icon"
version="1.1"
id="Layer_1"
x="0px"
y="0px"
viewBox="0 0 26 43"
style="enable-background: new 0 0 26 43"
xml:space="preserve"
>
<path
id="Path_3539"
class="st0"
d="M4.5,43C2,43,0,41,0,38.5c0-1.2,0.5-2.4,1.3-3.2l13.7-13.8L1.3,7.7c-1.7-1.8-1.7-4.7,0.1-6.4c1.8-1.7,4.5-1.7,6.3,0l16.9,17c1.8,1.8,1.8,4.6,0,6.4l-16.9,17C6.9,42.5,5.7,43,4.5,43z"
/>
</svg>
</button>
</swiper>
My TS
heroSlider: SwiperOptions = {
loop: false,
slidesPerView: 1,
on: {
transitionEnd: function (Swiper) {
console.log(Swiper);
},
},
};
If you simply mean you want to pause video when you click the next or previous buttons, you can add a listener for those buttons and in that listener pause the video.
Some example below showing adding an ID to the button and then using this to find the button in your Javascript and add a listener.
You can add a resume button also or just have the user click play on the video.
<button id="btnNext" class="btn p-0 btn-prev" (click)="previousSlide()">
var vid1 = document.getElementById("YourVideoID");
var btnNext = document.getElementById("NextButton");
var btnPrev = document.getElementById("PrevButton");
var btnResume = document.getElementById("PrevButton");
btnNext.addEventListener("click", function() {
vid1.pause()
});
btnPrev.addEventListener("click", function() {
vid1.pause()
});
btnResume.addEventListener("click", function() {
vid1.play()
});
I am trying to use * ngFor to create new "rows" as new categories are being added.
The problem is that when running the program, I do not receive any error but also do not get the intended. I've tried to add a few things, but everything under in * ngFor not "running" ... can anyone help me?
GetCategory() {
var self = this;
this.Global.refreshToken().subscribe(function (result) {
self.uploadService.getCategory().then(function (resultado) {
if (resultado) {
// self.category = resultado;
var categories = JSON.parse(resultado);
// console.log(categories);
} else {
}
}).catch();
});
}
<div class="bodyPermCardDam">
<div *ngFor="let category of categories; let i = index">
<ng-template>
<div class="categoryChoosedName catParm{{category.ID}}" (click)="SelectCategoryPerm(category.ID,1)">
<svg class="folder" id="folder{{category.ID}}" xmlns="http://www.w3.org/2000/svg" width="24" height="19.2" viewBox="0 0 24 19.2">
<style type="text/css">
.folder:hover .stSpecial,
.folder:active .stSpecial {
fill: #4981C2 !important;
}
.stSpecial {
transition: all 0.3s ease 0s;
}
</style>
<g transform="translate(-32 -92)">
<g transform="translate(28 84)">
<path class="stSpecial" d="M13.6,8H6.4a2.389,2.389,0,0,0-2.388,2.4L4,24.8a2.4,2.4,0,0,0,2.4,2.4H25.6A2.4,2.4,0,0,0,28,24.8v-12a2.4,2.4,0,0,0-2.4-2.4H16Z" fill="#caced5" />
</g>
</g>
</svg> {{category.Name}}
</div>
</ng-template>
</div>
</div>
Remove ng-template and your code should show results inside *ngFor. That's how <ng-template> works.
You need ng-container to render ng-template. Check this out
<div class="bodyPermCardDam">
<div *ngFor="let category of categories; let i = index">
<div class="categoryChoosedName catParm{{category.ID}}" (click)="SelectCategoryPerm(category.ID,1)">
<svg class="folder" id="folder{{category.ID}}" xmlns="http://www.w3.org/2000/svg" width="24" height="19.2" viewBox="0 0 24 19.2">
<style type="text/css">
.folder:hover .stSpecial,
.folder:active .stSpecial {
fill: #4981C2 !important;
}
.stSpecial {
transition: all 0.3s ease 0s;
}
</style>
<g transform="translate(-32 -92)">
<g transform="translate(28 84)">
<path class="stSpecial" d="M13.6,8H6.4a2.389,2.389,0,0,0-2.388,2.4L4,24.8a2.4,2.4,0,0,0,2.4,2.4H25.6A2.4,2.4,0,0,0,28,24.8v-12a2.4,2.4,0,0,0-2.4-2.4H16Z" fill="#caced5" />
</g>
</g>
</svg> {{category.Name}}
</div>
</div>
</div>
you need to declare a public list of categories in the component :
public categories : any[];
GetCategory() {
var self = this;
this.Global.refreshToken().subscribe(function (result) {
self.uploadService.getCategory().then(function (resultado) {
if (resultado) {
this.categories = JSON.parse(resultado);
} else {
}
}).catch();
});
}
and in the view wait for the data by adding an *ngIf :
<div class="bodyPermCardDam" *ngIf="categories">
<div *ngFor="let category of categories; let i = index">
...
</div>
</div>
I want to show the loading icon(spinner) when I hit the button the request is going from controller to server. It will take some time to respond mean while, I need to show any loading icon. Once the server respond to the controller I just want to disable the loading icon.
Html:
<div class="modal-content" style="margin-top:135px">
<div class="modal-header">
<h4 class="modal-title pull-left"> Add New Role</h4>
<button type="button" class="close pull-right"
data-dismiss="modal" aria-hidden="true" title="Close">
x
</button>
</div>
<div class="modal-body">
<div class="row" style="margin-bottom:1%">
<div class="col-xs-3">
<h6><strong>Role<span style="color:green;">*</span></strong></h6>
</div>
<div class="col-xs-9">
<input type="text" required name="RoleName" placeholder="Role Name" onkeyup="convertToUppercase(this)"
class="form-control" ng-model="Role.RoleName" ng-change="verifyRoleDuplicate()" />
</div>
</div>
<div class="row" style="margin-bottom:1%">
<div class="col-xs-3">
<h6><strong> Description</strong></h6>
</div>
<div class="col-xs-9">
<textarea name="Description"
style="width: 100%; max-height: 200px; max-width: 100%;" ng-model="Role.Description" maxlength="255"></textarea>
</div>
</div>
<div class="row" style="margin-bottom:1%">
<div class="col-xs-3">
<h6><strong>IsActive?</strong></h6>
</div>
<div class="col-xs-9">
<input type="checkbox" name="IsActive" class="form-control" ng-model="Role.IsActive" style="width:20px;" />
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-primary" ng-click="AddRole()" ng-disabled="disableds || profileformAdd.$invalid" data-dismiss="modal" title="Save">Save</button>
<button class="btn btn-primary" data-dismiss="modal" title="Cancel" >Cancel</button>
</div>
</div>
controller:
$scope.AddRole = function ()
{
$http.post('/AddNewRole', $scope.Role).then(function (response) {
//console.log(response);
$notify.success('Success', "New Role" + " '" + $scope.Role.RoleName +"' " + "is inserted Successfully");
refresh();
$scope.Role='';
})
};
when I click the add button It will open the popup, Popup has two buttons if I click save button I want to display the loading icon. after save functionality completed It should hide the loading icon.
You can use css or svg loader for the same.
Simple Example of loader is given below.
Demo: http://codepen.io/sumitridhal/pen/gWWORr
HTML
<div class="container" ng-app="myApp">
<div ng-controller="myController">
Button
<div class="loader loader--style1" title="0" ng-if="load">
<svg version="1.1" id="loader-1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="40px" height="40px" viewBox="0 0 40 40" enable-background="new 0 0 40 40" xml:space="preserve">
<path opacity="0.2" fill="#000" d="M20.201,5.169c-8.254,0-14.946,6.692-14.946,14.946c0,8.255,6.692,14.946,14.946,14.946
s14.946-6.691,14.946-14.946C35.146,11.861,28.455,5.169,20.201,5.169z M20.201,31.749c-6.425,0-11.634-5.208-11.634-11.634
c0-6.425,5.209-11.634,11.634-11.634c6.425,0,11.633,5.209,11.633,11.634C31.834,26.541,26.626,31.749,20.201,31.749z"/>
<path fill="#000" d="M26.013,10.047l1.654-2.866c-2.198-1.272-4.743-2.012-7.466-2.012h0v3.312h0
C22.32,8.481,24.301,9.057,26.013,10.047z">
<animateTransform attributeType="xml"
attributeName="transform"
type="rotate"
from="0 20 20"
to="360 20 20"
dur="0.5s"
repeatCount="indefinite"/>
</path>
</svg>
</div>
</div>
</div>
CSS
body{
padding: 1em;
background: #2B3134;
color: #777;
text-align: center;
font-family: "Gill sans", sans-serif;
width: 80%;
margin: 0 auto;
}
h1{
margin: 1em 0;
border-bottom: 1px dashed;
padding-bottom: 1em;
font-weight: lighter;
}
p{
font-style: italic;
}
.loader{
margin: 0 0 2em;
height: 100px;
width: 20%;
text-align: center;
padding: 1em;
margin: 0 auto 1em;
display: inline-block;
vertical-align: top;
}
/*
Set the color of the icon
*/
svg path,
svg rect{
fill: #FF6700;
}
JS
(function(){
var myApp = angular.module('myApp', []);
myApp.controller('myController', function($scope, $timeout){
$scope.load = false;
$scope.toggle = function (){
$http.get(someUrl).success(function(){
$scope.load = true;
// Logic goes here
$scope.load = false;
}).error(function(){
$scope.load = true;
// Logic goes here
$scope.load = false;
})
}
});
})();