Skip to content

Commit

Permalink
Merge pull request #447 from almothafar/master
Browse files Browse the repository at this point in the history
Fix demo and docs
  • Loading branch information
almothafar authored Sep 16, 2024
2 parents 8df572d + eddd1e5 commit bbf048f
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 39 deletions.
3 changes: 2 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
"builder": "@angular-devkit/build-angular:application",
"options": {
"outputPath": {
"base": "docs"
"base": "docs",
"browser": ""
},
"baseHref": "/auto-complete/",
"index": "projects/demo/src/index.html",
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions docs/browser/index.html → docs/index.html

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions docs/browser/main-SOUZ5HFM.js → docs/main-MP7MFDPQ.js

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions projects/auto-complete/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
],
"parserOptions": {
"project": [
"projects/auto-complete/tsconfig.lib.json",
"projects/auto-complete/tsconfig.spec.json"
"./tsconfig.lib.json",
"./tsconfig.spec.json"
],
"createDefaultProgram": true
},
Expand Down
6 changes: 6 additions & 0 deletions projects/demo/src/app/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export class AppService {
private marvelBase = 'http://gateway.marvel.com:80/v1/public/';
private marvelPublicKey = 'b9ced31de3874eb2c065a5bce26f8c59';

private googleMapsPublicKey = 'AIzaSyBjCWwFwEjaClobsRcY7mAlGSfCsRmD0Vg';

constructor(private _http: HttpClient) {
}

Expand All @@ -20,4 +22,8 @@ export class AppService {
public findHeroes = (startsWith: string): Observable<any[]> => {
return this._http.get<any>(`${this.marvelBase}characters?nameStartsWith=${startsWith}&apikey=${this.marvelPublicKey}`);
};

public getMapsUrl = () => {
return `https://maps.googleapis.com/maps/api/geocode/json?address=:my_own_keyword&key=${this.googleMapsPublicKey}`
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<legend><h2>Component test - multi autocomplete</h2></legend>
<div class="wrapper" (click)="showAutocomplete=true">
<li class="addr" *ngFor="let addr of addrs; let i = index;">
<span>{{addr.formatted_address}}</span>
<span class="remove" (click)="removeFromAddrs($event, i)">x</span>
<span>{{ addr.formatted_address }}</span>
<span class="remove" (click)="removeFromAddress($event, i)">x</span>
</li>

<ngui-auto-complete
*ngIf="showAutocomplete"
(valueSelected)="addToAddrs($event)"
(valueSelected)="addToAddress($event)"
[accept-user-input]="true"
[source]="googleGeoCode"
[source]="appSvc.getMapsUrl()"
display-property-name="formatted_address"
[list-formatter]="myListFormatter"
loading-text="Google Is Thinking..."
Expand Down
10 changes: 5 additions & 5 deletions projects/demo/src/app/component-test/component-test.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component } from '@angular/core';
import { AppService } from '../app.service';

@Component({
selector: 'app-component-test',
Expand All @@ -7,7 +8,6 @@ import { Component } from '@angular/core';
})
export class ComponentTestComponent {

public googleGeoCode = 'https://maps.googleapis.com/maps/api/geocode/json?address=:my_own_keyword';
public showAutocomplete = true;
public loadingTemplate = '<h1>Loading h1</h1>';
public addrs: any[] = [
Expand All @@ -28,7 +28,7 @@ export class ComponentTestComponent {
*ngIf="showAutocomplete"
(valueSelected)="addToAddrs($event)"
[accept-user-input]="true"
[source]="googleGeoCode"
[source]="appSvc.getMapsUrl()"
display-property-name="formatted_address"
[list-formatter]="myListFormatter"
loading-text="Google Is Thinking..."
Expand All @@ -54,15 +54,15 @@ export class ComponentTestComponent {
</ngui-auto-complete>
`;

constructor() {
constructor(public appSvc: AppService) {
}

public addToAddrs(addr: any): void {
public addToAddress(addr: any): void {
this.addrs.push(addr);
this.showAutocomplete = false;
}

public removeFromAddrs(evt, index: number): void {
public removeFromAddress(event, index: number): void {
this.addrs.splice(index, 1);
event.stopPropagation();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h1> Autocomplete Directive Test - Local Source </h1>
id="model4"
[(ngModel)]="model4"
placeholder="Enter Address(min. 2 chars)"
[source]="googleGeoCode"
[source]="appSvc.getMapsUrl()"
no-match-found-text="No Match Found"
list-formatter="formatted_address"
path-to-data="results"
Expand All @@ -76,7 +76,7 @@ <h1> Autocomplete Directive Test - Local Source </h1>
min-chars="2" />
<br/>selected model4: {{model4 | json}}<br/><br/>
<pre>{{template5}}</pre>
<pre> source: {{googleGeoCode}}</pre>
<pre> source: https://maps.googleapis.com/maps/api/geocode/json?address=:my_own_keyword</pre>
</fieldset>

<fieldset><legend><h2>Source as Observable "Marvel API"</h2></legend>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Component, ViewEncapsulation } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { AppService } from '../app.service';

@Component({
Expand Down Expand Up @@ -47,8 +46,6 @@ export class DirectiveTestComponent {
{city: 'Dallas', state: 'Texas', nickname: 'The Big D', population: '1,317,929'},
{city: 'San Jose', state: 'California', nickname: 'Capital of Silicon Valley', population: '1,025,350'}];

public googleGeoCode = 'https://maps.googleapis.com/maps/api/geocode/json?address=:my_own_keyword';

public model1 = 'is';
public model2 = {id: 1, value: 'One'};
public model3 = {key: 3, name: 'Key Three'};
Expand Down Expand Up @@ -194,10 +191,7 @@ export class DirectiveTestComponent {
`;


constructor(
public appSvc: AppService,
public http: HttpClient
) {
constructor(public appSvc: AppService) {
}

public customCallback(text) {
Expand Down
2 changes: 1 addition & 1 deletion projects/demo/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>Demo</title>
<title>Angular auto-complete Showcase</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
Expand Down

0 comments on commit bbf048f

Please sign in to comment.