My url is this http://localhost/fcm/Maps/create_deped_cm/1/1/1 . When I use my https in angular the response would be a php page because the post url will be http://localhost/fcm/Maps/create_deped_cm/1/1/do_add_deped_cm . When I test and find the answer the post url should be http://localhost/fcm/Maps/do_add_deped_cm . How can I achieve this?
angularjs code:
<script type="text/javascript">
angular.module('config', [])
.constant('appName','My Angular App!')
.constant('appVersion','0.3')
.constant('baseUrl','http://localhost/fcm/');
var app = angular.module("myCurriform_deped", ['config']);
app.controller("standardCtrl", function($scope,$http,$filter,$location,$window,config) {
.......................
});
You need to defined a base url in your app's config file:
angular.module('myApp.config', [])
.constant('appName','My Angular App!')
.constant('appVersion','0.3')
.constant('baseUrl','http://localhost/fcm/');
Make sure your config is included in your module:
angular.module('myApp', ['myApp.config']);
Then just append your url to the base and use that:
var url = config.baseUrl + 'Maps/do_add_cm_deped'
That should do the trick.
app.js
angular
.module('config', []).constant('baseUrl','http://localhost/fcm/');
angular
.module('myCurriform_deped', ['config'])
.controller("standardCtrl", function($scope,$http,$filter,$location,$window,config) {
$scope.submit_button = function(params) {
// submit logic
var url = config.baseUrl + 'Maps/do_add_cm_deped';
var req = {
url: url,
// other properties
}
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.