[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

Angular

589

Solutions

394

Contributors

Angular is a JavaScript open-source web application framework used to develop single-page applications. It aims to simplify both the development and the testing of such applications by providing a framework for client-side model–view–controller (MVC) and model–view–view-model (MVVM) architectures, along with components commonly used in rich Internet applications. Angular is the front-end part of the MEAN stack, together with Node.js runtime, Express.js backend framework and MongoDB database.

Share tech news, updates, or what's on your mind.

Sign up to Post

We are trying to POST to a WCF REST method. We can successfully POST using SoapUI, Postman, and YARC but when we try in Angular 5 I'm receiving a NULL object.

Client code:
    const headers: any =  {'Content-Type': 'application/json'};
    return this.ajax.request<any>({
        url: url,
        method: method (POST),
        headers: headers,
        options: {
            body: JSON.stringify(req.body)
        }
        });
    }

    public request<T>(req: AjaxRequest): Observable<HttpEvent> {
        return this.http.request<T>(req.method, req.url, req.options)
    }

    //this.http = HttpClient

    // Component
    public onNext(event: any): void {
        this._saveInfo(getInsertDmgReqPayload({
            data: event.value,
            dmgInfo: this.responses['dmg'],
            emailId: this.util.getQueryStringValue('uname')
        }));

        this.util.navigate('education');
    }

    private _saveInfo(data: any): void {
        this.appraisal.request('saveDmgInfo', null, {body: data})
        .subscribe(v => {
            console.log(v);
        });
    }

Open in new window


Server-side logic:
// WCF Interface definition
    [OperationContract]
    [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
    Result InsertDemographicInfo(Demographic d);

    // Service code
    public Result InsertDemographicInfo(Demographic d) // The Demographic object is null when posting from Angular
    {
        Result result = new Result();
        try
        {
            DemographicFactory.InsertDemographicInfo(d);
            result.Status = "Success";
        }
        catch (Exception ex)
        {
            result.Status = "Fail";
            result.Message = ex.Message;
        }
        return result;
    }

Open in new window


Web config:

Open in new window

0
Fundamentals of JavaScript
LVL 12
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

Hi all,
from my Angular 6 form I should send some data reproducing the same configuration which I have in Postman (I send a screenshot with the complete configuration: not "form" but raw / Json).

How can I do this? Thank you very much. I searched some solutions but I found example only in other cases.

registration.png

EDIT I try to edit to make my question more clear (I saw the -1 score, sorry if it is not clear). I have a set of data already retrieved from my Angular 6 / Material Design form and now I would sent this data to my backend (localhost:8080/something...). The configuration for this http post operation is in the attached screenshot: in my body, I choosen raw / Json options and all works correctly. Now, I should reproduce the same sent action also in my typescript component. How can I this request make? I tested some solutions but without any success. Thank all!

This is my code which doesn't work:


public login() {

        let userPassword = this.registrationForm.get('password').value;
        let userLogin = this.registrationForm.get('email').value;
        let userLangKey = 'en';

        const transferObject = {

            password: userPassword,
            login: userLogin,
            langKey: userLangKey
        }

        //JSON.stringify(transferObject);

        const req = this.http.post('http://localhost:8080/api/register/', {
            password: userPassword,
            login: userLogin,
            langkey: 

Open in new window

0
I am trying to edit a form in Angular 6 + Material Design. In the above code, I have 1 problems.

I would change the fa-envelope icon and I have searched in the Material Design folder, according to the tutorial I found. But no icon info or link was there; how are icons in material design managed? How can I change it?

Thanks all

    <form (ngSubmit)="login()" [formGroup]="registrationForm">
    	<div class="mt-4">
    	<mat-icon matPrefix fontSet="fa" fontIcon="fa-envelope" class="fa-24px text-center mr-3"></mat-icon>
    	<mat-form-field class="w-100">
    	   <input type="email" formControlName="test" matInput placeholder="Deine Name" required="required">
    	</mat-form-field>
    (...)

Open in new window

0
How  can I  resolve  this Error?I am a newbie in Graphql..I am trying  to call  graphql  API in angular.Below is my  code

export type DataTagsNames = {
	DATA_TAG_NM:String;
	DATA_TAG_ID:String;
	DSPLY_LINE_CNT:String;
	FLD_ENBL_IND:String;
	CNTXT_SCRN_IND:String;
	SHOW_DATA_IND:String;
	INJ_IND:String;
	RLT_ENTY_NM:String;
	CNTXT_SCRN_GRP_NM:String;
	PRTPT_TYPE_CD:String;
	DATA_TAG_PRTPT_CD:String;
	DATA_TAG_PRFM_R_CD:String;
	READ_ONLY_IND:String;
	EMTY_DLTE_IND:String;
	STWRD_EDT_IND:String;
}

export type Query = {
	allDataTagsNames: DataTagsNames[];
}

Open in new window

export class ListComponent implements OnInit {
  datatagsdetails: Observable<DataTagsNames[]>;
  constructor(private apollo: Apollo) { }

  ngOnInit() {
    this.datatagsdetails = this.apollo.watchQuery<Query>({
      query: gql`
        query allDataTagsNames {
          DataTagsNames {
           
          DATA_TAG_NM
           DATA_TAG_ID
           DSPLY_LINE_CNT
           FLD_ENBL_IND
           CNTXT_SCRN_IND
           SHOW_DATA_IND
           INJ_IND
           RLT_ENTY_NM
           CNTXT_SCRN_GRP_NM
           PRTPT_TYPE_CD
           DATA_TAG_PRTPT_CD
           DATA_TAG_PRFM_R_CD
           READ_ONLY_IND
           EMTY_DLTE_IND
           STWRD_EDT_IND

          }
        }
      `
    })
      .valueChanges
      .pipe(
        map(result => result.data.allDataTagsNames)
      );

Open in new window

0
I am trying to use Angular 7's drag and drop cdk to drag and drop mat-card. My code is quite complicated. I am creating mat-grid dynamically according to grid number (Raster is the property in JSON for this - in German). I want to just change the mat-card embedded in tile but when I drag one card from one place to another, entire layout of my grid changes. I dont want this. I just want to change the card from one postion to another. Below is my code.

Raster.component.html

<mat-grid-list cdkDropList class="example-list z-depth-5" cols="3" rowHeight="180px" gutterSize="8px" (cdkDropListDropped)="drop($event)">
  <mat-grid-tile class="example-box z-depth-4" *ngFor="let tile of tiles; let i = index" [colspan]="tile.cols" [rowspan]="tile.rows" cdkDrag>
    <mat-card class="add-new-flyer" *ngIf="tile.flyer == '-1'" id="p_{{tile.flyer}}">
      <div fxLayout="row" fxLayout.xs="column" fxLayoutWrap fxLayoutAlign="space-evenly">
        <div fxLayout fxLayout fxLayout.xs="column" fxLayoutAlign="end" fxLayoutGap="10px" fxLayoutGap.xs="0">
          <div class="button">
            <button mat-mini-fab (click)="addNewWerbedata(tile.text)">
              <mat-icon>add</mat-icon>
            </button>
          </div>
        </div>
      </div>
    </mat-card>
    <mat-card class="flyer-card" *ngIf="tile.flyer !== '-1'" id="p_{{tile.text}}">
      <div class="container" fxLayout fxLayout.xs="column" fxLayoutAlign="left" fxLayoutGap="10px" fxLayoutGap.xs="0">
        <div 

Open in new window

0
Hi all,
in the official ng-book (p. 73) I read that is possible indicate an angular 6 component tag in 2 different ways. Example from the official manual:

1) <inventory-app-root></inventory-app-root>
2) <div inventory-app-root></div>

but in my Angular application only the 1st way works.


<app-test-component></app-test-component>
(work)

 <div app-test-component></div>
(doesn't work)

Why?
Thank you very much
0
Hi i just purchased Winzip 22 yesterday


I'm trying to run a gzip application from the command line via http-server


eg.  http-server gzip
to gzip the Angular bundles down to a much smaller size


Any ideas how I can do this?


Gordon Cumming
0
Hi,

I work on a nativescript angular application and wanted to schedule some tasks (example: each 10 minutes) where I do http requests, call my angular services, ...
Now, when the android phone is locked and charging there are no issues, but when the phone isn't charging and locked that's when stuff goes wrong.
The call is still handled (so my function gets handled), but my http calls take ages, and when I wake up the phone everything operates normally again.

Is there something I can do to go around this ? To have the http requests etc still going

Tested on galaxy s7
0
Hi experts. I'm integrating angular into my aspnet core project. Issue is, I can't seem to render my component(which I used as a tag in my .cshtml view). When i checked my console for the errors, I saw that it came with the runtime, polyfills, style, etc which I used in my <head> element..I removed them all, still didn't render... Is there a basic configuration I'm supposed to do before my angular component selectors can work as tags in my html? Thanks in advance
0
Spring Boot and Angular: Serving static content

Hi Experts,

I have a springboot backend application and an angular front end. I have built the angular front-end copied the contents of dist directory to /src/main/resource/static.  The index.html in the static directory is served when I go to https://localhost:8443 and the links are working.  However, when I refresh the page, it goes to the whitelabel error page.  I have found a proposed solution to this from StackOverflow.  It too doesn't work.
@Controller
public class ForwardController {

    @RequestMapping(value = "/**/{[path:[^\\.]*}")
    public String redirect() {
        // Forward to home page so that route is preserved.
        return "forward:/";
    }
} 

Open in new window

However, using this just prints forward:/ on the refreshed browser.   Also, this too does not look like the solution I want.  I want to just refresh the page.
Any help would be appreciated.  Thank you
0
Why Diversity in Tech Matters
LVL 12
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

Can't get bootstrap modal working. Just button is showing up but clicking on it doesn't do anything. Below is my app.component.html content from Angular.

<html>

<head>
  <title></title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
  <!-- Bootstrap -->
  <!-- Latest compiled and minified CSS -->
  <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css">
  <!-- Optional theme -->
  <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap-theme.min.css">
  <!-- Latest compiled and minified JavaScript -->
  <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"></script>
</head>

<body>
  <div class="content-fluid base-padding-top">
    <main>


     <button type="button" class="btn btn-primary btn-large" data-toggle="modal" data-target="#myModal">Launch demo modal</button>

      <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="purchaseLabel" aria-hidden="true">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
              <h4 class="modal-title" id="purchaseLabel">Purchase</h4>
            </div>
            <div class="modal-body">
          

Open in new window

0
Good day, how do i link my aspnet mvc view with my angular? Thanks.
0
Hi, I asked a question yesterday on how to integrate angular into my existing aspnet mvc app(vs 2017). It got solved as I could include angular folders. I'm a bit confused now, as to how to route my model-controller-view. Angular is supposed to be my front end technology, am I to include my controllers as classes in my angular src folder(.ts) or what? I'll love access to an article or github repo that clearly explains this concept of angular with MVC. Thanks Experts.!
0
Hi,

We have mobile application, which is developed using  ionic one, CoffeeScript and angular one. When we build the application for the android and web, all images are showing correctly. But we build same application for IOS it not showing the images. Image path is correct and images is available inside of application bundle folder.

Also this application use cordova plugin file for the file management. All the images are getting from IOS application bundle.

When we build for IOS there is no errors or warnings.
screen-1.JPG
screen-2.JPG
0
Unable to install Angular on mac I got this error:
npm ERR! path /usr/local/bin/ng
npm ERR! code EEXIST
npm ERR! Refusing to delete /usr/local/bin/ng: ../lib/node_modules/angular-cli/bin/ng symlink target is not controlled by npm /usr/local/lib/node_modules/@angular/cli
npm ERR! File exists: /usr/local/bin/ng
npm ERR! Move it away, and try again.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/saudalsahli/.npm/_logs/2018-09-02T09_31_09_443Z-debug.log
sauds-MacBook-Pro:~ saudalsahli$ sudo npm install -g @angular/cli
npm ERR! path /usr/local/bin/ng
npm ERR! code EEXIST
npm ERR! Refusing to delete /usr/local/bin/ng: ../lib/node_modules/angular-cli/bin/ng symlink target is not controlled by npm /usr/local/lib/node_modules/@angular/cli
npm ERR! File exists: /usr/local/bin/ng
npm ERR! Move it away, and try again.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/saudalsahli/.npm/_logs/2018-09-02T09_33_27_509Z-debug.log
0
For any new Product development which technology is best - Angular / MVC Core / React ?
0


I have so for been updating the data. Now when some lecturer writes say, completed in the comments section and checks completed radio button. Now next time when the same teacher checks it then it must show that the sub/chap has been completed. So how to do that in angularjs and php? Any help would be appreciated. Please do help me i am stuck.
0
I'm using visual studio code version 1.26.1 for angular projects. Right now I'm using source control GIT. But I would like to change this to Team Foundation Server.
So that I have installed the Visual Studio Team Services. Once after that, I have done the following things.

Open File -> Preferences -> Settings

Add the following lines to your user settings
{
  "tfvc.location": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer\\tf.exe",
    "tfvc.restrictWorkspace": true
}

Open a local folder (repository), From View -> Command Pallette ..., type team signin

when I select the sign in from command palette I got the following error

"(team) No Team Services or Team Foundation Server repository configuration was found. Ensure you've opened a folder that contains a repository.

Please let me know how to set up the Team Foundation Server repository. Do I need to uninstall the GIT for use the TFS? Please let me know?
0
I am using Angular 6 and tried to hide sidenav bar in Login component. Once user logins, he can see navigation bar. (I have created fake backend for this project as this is just a prototype for my project.)

My problem is, I have to refresh to get sidenav bar on app component.

Can someone help me to solve this?

App.component.ts

export class AppComponent implements OnInit, OnDestroy {

  // Translate: Defining Supported Languages
  supportedLangs = [
    { active: false, display: 'EN', value: 'en' },
    { active: true, display: 'DE', value: 'de' },
  ];

  isOpen = false;
  loggedIn: boolean;
  username: string;
  mobileQuery: MediaQueryList;

  // defines if the sidenav should be opened. True in wide screen, false on mobile
  opened = true;
  // can be side or over, for resp wide screen and mobile
  over = 'side';

  watcher: Subscription;

  constructor(private media: ObservableMedia,
    private authenticationService: AuthenticationService,
    private router: Router,
    private sidebarService: SideBarService,
    private translate: TranslateService) {
    this.watcher = media.subscribe((change: MediaChange) => {
      // this language will be used as a fallback when a translation isn't found in the current language
      translate.setDefaultLang('en');
      translate.use('en');
      if (change.mqAlias === 'sm' || change.mqAlias === 'xs') {
        // mobile
        this.opened = false;
        this.over = 'over';
      } else {
        // wide screen
 

Open in new window

0
HTML5 and CSS3 Fundamentals
LVL 12
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

Disable client-side caching in all browser. We are using Angualrjs.
For disabling the cache, I used HTML meta tags:-
    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="EXPIRES" content="0">
    <meta http-equiv="PRAGMA" content="NO-CACHE">
but need a best solution
i.e.: http://www.i18nguy.com/markup/metatags.html
0
Hi, I am using Kendo Grid in UI using angular. I am executing a dynamic query which returns data; it displays data but the columns are not with proper width. Below is the code I use:

 vm.BindUserData = function (gridData) {
            $("#gridUserQueryResults").kendoGrid({
                dataSource: {
                    data: gridData,
                    pageSize: 50
                }
                , resizable: true
                , height: (vm.Dimensions.height * .65)
                , scrollable: true
                , reorderable: true
                , pageable: {
                    buttonCount: 10,
                    previousNext: true,
                    input: false,
                    pageSizes: [10, 15, 25, 50, 100, 500]
                }
                , columns: vm.GridColumns
                , sortable: {
                    mode: "single",
                    allowUnsort: true
                }
                , filterable: {
                    extra: false,
                    operators: {
                        string: {
                            startswith: "Starts with",
                            eq: "Is equal to",
                            neq: "Is not equal to",
                            contains: "Contains",
                            endswith: "Ends with"
                        }
                    }
                }
            });


        };

where gridData is DataTable returned from …
0
exported pdf
I am tried to export pdf UI grid data along with multiple line title and image logo. its setting only first three line as title line even there was more than 3 line in code.
exported pdf file has been attached and wan  to set logo yellow mark position on pdf.
Could you please help me? Thanks in advance


vm.gridOptions = {
                enableFiltering : true,
                enableGridMenu : true,
                onRegisterApi : function(gridApi) {
                    $scope.gridApi = gridApi;
                },

                exporterCsvFilename : 'myfile.csv',

                  exporterPdfHeader: {
                        text: [
                            'line 1',
                            {text: 'hello altruist\nplease \nhelp me'},
                            'end of line 1\n',
                            'Second line \n',
                            'Third line\n',
                            'fghfhgf line\n',
                            'Third line'
                        ], style: 'headerStyle'
                    },

                    exporterPdfFooter: function ( currentPage, pageCount ) {
                          return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
                        },
                        exporterPdfCustomFormatter: function ( docDefinition ) {
                            docDefinition.styles.headerStyle = { fontSize: 10, bold: …
0
I am implementing google map in Angular 5 using npm library googlemaps.
When trying to show route/path between 2 points using setDirections(),I am unable to see the path.The 2 points are shown but no route is drawn and there is even no error in console.
Following is the code use for showing route:

var mapProp = {
center: new google.maps.LatLng(22.0824, 82.1411),
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
 
this.map = new google.maps.Map(this.gmapElement.nativeElement, mapProp);
this.directionsDisplay.setMap(this.map);
this.marker1 = new google.maps.Marker({
map: this.map,
draggable: true,
position: { lat: 22.0717, lng: 82.1497 }
});
this.marker2 = new google.maps.Marker({
map: this.map,
draggable: true,
position: { lat: 22.0942, lng: 82.1257 }
});
 
google.maps.event.addListener(this.marker1, 'position_changed', this.update);
google.maps.event.addListener(this.marker2, 'position_changed', this.update);
 
this.lat1 = 22.0717;
this.lang1 = 82.1497;
this.lat2 = 22.0942;
this.lang2 = 82.1257;
this.Source = new google.maps.LatLng(this.lat1, this.lang1);
this.Destination = new google.maps.LatLng(this.lat2, this.lang2);
 
var request = {
origin: this.Source,
destination: this.Destination,
travelMode: google.maps.TravelMode.DRIVING
}
 
this.directionsService.route(request, function (response, status) {
if (status === google.maps.DirectionsStatus.OK) {
new google.maps.DirectionsRenderer().setDirections(response);
} else
   {
window.alert('Directions request 

Open in new window

0
I have a function in Angular JS as below

getAllCurrency(): Promise<any> {
	return this._httpService
		.get('/api/Order/GetCurrentCurrency')
		.toPromise()
		.then(result => {
			debugger;
			return result;
		})
		.catch(this.handleError);
}

Open in new window


When this function called it gives below error

this._orderService.getAllCurrency().then(result => {
            if (result != null) {
                this.allCurrencyPrice = result;
            }
        });

Open in new window



vendor.944c2d2d1376bd2e8849.bundle.js:1 ERROR Error: Uncaught (in promise): Http failure response for https://example.com/api/Order/GetCurrentCurrency: 503 OK
    at c (polyfills.7ca9766913fb3444ee06.bundle.js:1)
    at c (polyfills.7ca9766913fb3444ee06.bundle.js:1)
    at polyfills.7ca9766913fb3444ee06.bundle.js:1
    at t.invokeTask (polyfills.7ca9766913fb3444ee06.bundle.js:1)
    at Object.onInvokeTask (vendor.944c2d2d1376bd2e8849.bundle.js:1)
    at t.invokeTask (polyfills.7ca9766913fb3444ee06.bundle.js:1)
    at r.runTask (polyfills.7ca9766913fb3444ee06.bundle.js:1)
    at o (polyfills.7ca9766913fb3444ee06.bundle.js:1)
    at e.invokeTask [as invoke] (polyfills.7ca9766913fb3444ee06.bundle.js:1)
    at h (polyfills.7ca9766913fb3444ee06.bundle.js:1)
b @ vendor.944c2d2d1376bd2e8849.bundle.js:1
/api/Balance/GetPendingWithdrawal/BTC:1 Failed to load resource: the server responded with a status of 503 ()
main.1d1978b4ff1814cc159f.bundle.js:1 

Open in new window


What can be the reason behind this?
0
one thing I want you to share your thoughts on how we can go ahead with the rebuilding of a website. What are the things according to you should be implemented on the website?
we would like to rebuilding of this site using  Angular 4 and Laravel 5
0

Angular

589

Solutions

394

Contributors

Angular is a JavaScript open-source web application framework used to develop single-page applications. It aims to simplify both the development and the testing of such applications by providing a framework for client-side model–view–controller (MVC) and model–view–view-model (MVVM) architectures, along with components commonly used in rich Internet applications. Angular is the front-end part of the MEAN stack, together with Node.js runtime, Express.js backend framework and MongoDB database.

Top Experts In
Angular
<
Monthly
>