Retreving current domain in Angular model (angular service where ajax calls reside) to prepare full api url to retrieve data

22,094

You can use the $location service for that.

$log.info($location.absUrl());
$log.info($location.protocol() + "://" + $location.host() + ":" + $location.port());

But if you use relative URLs starting with a '/' to access your back-end, you should also get the behavior you want.

Share:
22,094

Related videos on Youtube

Karunaker Reddy V
Author by

Karunaker Reddy V

Overall 16+ years of relevant IT experience with emphasis on E-Commerce (B2B), B2C and Internet Technologies in an Application Development environment having good exposure with requirement analysis, software design, development and maintenance using Java/.net and Sql Server/MySql/PostgreSql/MongoDb/Cassandra/Redis/Elasticsearch/Solr/Lucene with client side stack like AngularJs/TypeScript/React/Bootstrap/Foundation/MaterialUI/Less/Saas. • In depth exposure to Web 2.0 solutions, developing web services, OOAD architecture and modeling and designing artifacts to satisfy peculiar and complex business problem statements. • Strong Programming Skills in designing and implementation of multi-tier applications using .net/java/j2ee, microservices, C#, Asp.net, HTML5, Javascript, JQuery/Angularjs/Typescript/ReactJs, CSS/LESS/SASS/Bootstrap/Foundation, IIS/Apache Tomcat/Jetty/nginix using Docker etc.. • Experienced in Web Services approach for Service Oriented Architecture (SOA). Used REST as the Web Service framework for creating and deploying Web Service clients. • Specialized in RDBMS design using normalization techniques and expertise in using SQL and PL/ SQL to write Stored Procedures, Functions, Packages and Triggers.NoSql/Cassandra etc. • Experienced in integrating payment gateways with the application. • A good team player with strong analytical skills, meticulous nature and a persevering attitude. A Fast learner with good communication skills. • Strong in Coding, development and design of applications and implementation knowledge of Object Oriented Analysis and Design using agile methodologies. • Deployed the projects in client Production environments • Strong communication & relationship management skills, enthusiastic & self-driven, With a high degree of commitment. • Successful in both technical and customer-facing roles, developing both front-end and back-end software, able to transform complex specifications or business requirements into intuitive GUIs • Given successful training over .Net trainee projects for MNC trainees.

Updated on April 03, 2020

Comments

  • Karunaker Reddy V
    Karunaker Reddy V about 4 years

    We have demo and live sites when we deploy application to demo it should work in demo like wise in live. demo url will be like demo.xxxx.com and live will be like xxxx.com.

    In angular service layer i'm calling asp.net webapi methods to access data. So I need to prepare url for this I need current domain (app root path). So that I can prefix this path to the webapi path hence I can call webapi method.

  • Karunaker Reddy V
    Karunaker Reddy V about 10 years
    I've used it but it didn't work earlier due to some other issue, but it is working now. thx.