AngularJS – Templates not working

Issue I am using Restangular to create a simple API using MEAN stack. Here is my code: index.html <!DOCTYPE html> <html data-ng-app=”scotchTodo”> <head> <!– META –> <meta charset=”utf-8″> <meta name=”viewport” content=”width=device-width, initial-scale=1″><!– Optimize mobile viewport –> <title>Node/Angular Todo App</title> <!–

Continue reading

How to get this data in relation models with Sails.js+Angular.js and RestAngular

Issue How to get data of this models: //User.js module.exports={ name:{ type:’string’ }, pets:{ collection:’pet’, via:’owner’ }, cars:{ collection:’car’, via:’owner’ } } //Pet.js module.exports={ name:{ type:’string’ }, owner:{ model:’user’ }, doctors:{ collection:’doctor’, via:’pets’ } }; //Car.js module.exports={ color:{ type:’string’ },

Continue reading

Restangular error – "then is not a function" when trying to resolve promise

Issue This is my service. (function() { ‘use strict’; angular .module(‘amazonScraperWebClient’) .factory(‘dataService’, dataService); /** @ngInject */ function dataService(Restangular) { Restangular.setBaseUrl(‘http://localhost:3000’); var data = { getProductList:getProductList }; function getProductList() { return Restangular.all(‘products’).getList(); } return data; } })(); This is the function

Continue reading

Restangular application

Issue I have an angularJs application with restAngularJS. Application is working fine on Desktop browsers. When I am trying same on Ipad (chrome / safari / firefox) application is not working. I am getting 304 code on apache log. Any

Continue reading

addResponseInterceptor in restangular controller

Issue I’m pretty new with AngularJS and I’m trying to use restangular to call my server Rest API that returns me this json: {“Users”:[{“AN01_ID”:1,”AN01_NAME”:”cust1″,”AN01_REF”:1,”AN01_ALT”:4},{“AN01_ID”:2,”AN01_NAME”:”cust2″,”AN01_REF”:2,”AN01_ALT”:3},{“AN01_ID”:3,”AN01_NAME”:”cust3″,”AN01_REF”:3,”AN01_ALT”:2},{“AN01_ID”:4,”AN01_NAME”:”cust4″,”AN01_REF”:4,”AN01_ALT”:1}],”ResponseStatus”:{}} from what I’ve read in the docs I need to set the addResponseInterceptor in config to

Continue reading

Testing a Restangular responseInterceptor

Issue What is the best way to do a unit test on a Restangular responseInterceptor? For instance: .config([‘RestangularProvider’, function(RestangularProvider){ RestangularProvider.setDefaultHttpFields({cache: true, withCredentials: true}); RestangularProvider.addResponseInterceptor(function (data, operation, what, url, response, deferred) { console.log(‘response from ‘+ url); console.log(data); var extractedData; // ..

Continue reading

Angularjs/Restangular, how to name file blob for download?

Issue For some reason this seems easier in IE than Chrome/FF: $scope.download = function() { Restangular.one(myAPI) .withHttpConfig({responseType: ‘blob’}).customGET().then(function(response) { //IE10 opens save/open dialog with filename.zip window.navigator.msSaveOrOpenBlob(response, ‘filename.zip’); //Chrome/FF downloads a file with random name var url = (window.URL || window.webkitURL).createObjectURL(response);

Continue reading

how to put param(body) in restangular?

Issue I have api that required parameter in body, so I need to put that values in restangular, I have tried this function deleteAccount(){ $log.log(accountIdDelete); Restangular.one(apiDeleteAccount).customDELETE( undefined, [ {id : accountIdDelete}, {ContentType:’application/x-www-form-urlencoded’} ]).then(function(response){ $log.log(response); var index = vm.account.indexOf(accountIdDelete); if (index

Continue reading

restangular patch nested field

Issue I’m having troubles patching a nested object with Restangular. The object I’m patching to: { “unread_notification_count”: 18, “notification_settings”: { “mention”: { “email_notification”: true, “platform_notification”: true, “desktop_notification”: true }, “history_update”: { “email_notification”: true, “platform_notification”: true, “desktop_notification”: true }, “assign”: {

Continue reading

Angularjs – Restangular call inside factory/service

Issue I am using factory as follows: var appModule = angular.module(‘appModule’, [‘ngRoute’,’restangular’]); appModule .config([‘$routeProvider’, function($routeProvider) { $routeProvider .when(‘/home’, { templateUrl: ‘home.html’, controller: ‘ngHomeControl’ }) .when(‘/contacts’, { templateUrl: ‘contacts.html’, controller: ‘ngContactControl’ }); }]); appModule .factory(‘testFactory’, function testFactory(Restangular) { return { getFriendList:

Continue reading

how to display object

Issue I am using Restangular and PHP REST service I am able to fetch data from PHP REST via calling from RestAngular. My code looks like angular .module(“classManagement”) .controller(‘ClassSectionListCtrl’, function (Restangular) { var vm = this; vm.currentYr = Restangular.one(“currentYear”).getList().$object; })

Continue reading

Restangular – getList in response

Issue can you say me what I am do wrong ? var api = Restangular.all(‘person’); api.getList().then(function(data) { angular.forEach(data, function(val,key) { val.getList(‘role’).then(function(res) { //… }); });}); I want call /person/:id/role , but now call /person/role … Thanks for any advice Solution

Continue reading

JSON from flask

Issue I’m trying to fetch data from an url generated with flask not from me with angularjs and restangular. I have this json data: {“patients”: [“{\”_id\”: {\”$oid\”: \”5677d634cc18e44063fa3556\”}, \”id_patient\”: \”2015120001\”, \”last_name\”: \”Chiacchiaretta\”, \”first_name\”: \”Piero\”, \”gender\”: \”M\”, \”birthdate\”: {\”$date\”: 307238400000}, \”birthplace\”:

Continue reading

angularJS how to manipulate resolve returm

Issue I am using AngularJS and RESTAngularJS. My resolve return correct JSON. for example “subject” 0: {subjectId: “1”, subjectCode: null, subjectLongName: “English”, subjectShortName: “English”} 1: {subjectId: “2”, subjectCode: null, subjectLongName: “Hindi”, subjectShortName: “Hindi”} 2: {subjectId: “3”, subjectCode: null, subjectLongName: “Maths”,

Continue reading

Angular Service Restangular Caching

Issue Are there scenarios where an angular service will cache Restangular/$http calls without being explicitly told to do so? For example I have a service doing something like this: function getSomeThings(){ return Restangular.one(‘things’).get().then(function (thing) { return thing; }); } This

Continue reading

Pass parameters in RESTAngular

Issue I am using angularJS, RESTangular. I need to pass 3 parameter. When I an passing 1 parameter like below, I am getting data subjectAllocationEdit: function (Restangular, $stateParams ) { return Restangular.one(‘subjectAllocationEdit’, $stateParams.classId).get(); } BUT if I am passing 3

Continue reading

Restangular ui.router resolve asynchronous or synchronous

Issue I am using Restangular and ui.router. Below is my code. app.config([“$urlRouterProvider”, “$stateProvider”, “$locationProvider”,”RestangularProvider”, function ($urlRouterProvider, $stateProvider, $locationProvider, RestangularProvider ) { $urlRouterProvider.otherwise(“/”); $stateProvider // .state(“home”, { url: “/”, templateUrl: ‘app/class/html/classList.html’, controller: ‘ClassSectionListCtrl as vm’, resolve: { acYear: function (Restangular, $stateParams)

Continue reading

restangular multiple api sources

Issue I can set one api provider per angularjs app for restangular like this RestangularProvider.setBaseUrl(‘http://localhost:8080/api’); but how do i setup multiple base url’s and use them selectively. I want to configure and use both of below end points RestangularProvider.setBaseUrl(‘http://localhost:8080/api’); RestangularProvider.setBaseUrl(‘http://localhost:8090/apiws’);

Continue reading

ui-router doesn't load states

Issue i have little problem with my code: https://github.com/burnpiro/angular-blog live version is available on http://erdem.pl/#/ Problem is that after deploying it on my server routing doesn’t work. ui-router not even trying to load template or controller into ui-view. Application starts

Continue reading

Restangular and _links

Issue I’m working on a AngularJS app. The app consumes a RESTful/HATEOAS API. The API has the following endpoint, amongst others: http://localhost:8001/api/tests/1 which returns: { “title”: “Test”, “description”: “Test”, “created”: “2016-01-09T11:52:01+0100”, “enabled”: true, “is_speed_test”: true, “test_id”: 1, “view”: [], “report_card”:

Continue reading

AngularJs cannot read property 'then' of undefined

Issue I have an authenticationService which contains this function: //this.userApi = Restangular.service(‘api/sessions’); login(user) { let that = this; this.userApi.post(user).then(function(user) { that.session.create(user.sessionId, user.userId, user.username); return user; }); } And in my controller: login() { this.authService .login(that.user) .then(function(user) { $scope.setCurrentUser(user); }, function(result)

Continue reading

"bound m" show in angular ng-repeat

Issue I use restangular to connect to REST API. I define a ProductService.js with this code: ‘use strict’; angular.module(‘app’).service(‘ProductService’, function($rootScope, Restangular) { // Build collection /product URL var _productService = Restangular.all(‘product’); this.list = function() { // GET /api/product return _productService.getList();

Continue reading

Restangular error handling issue

Issue I’m having an issue with restangular. This code : Restangular.one(“undefined_ressource”).get().then( function(res){ console.log(“success”, res.code); }, function (res) { console.log(“fail”, res.code); } ); Tries to get the url http://api.local.com/undefined_ressource which does not exits. My server returns a 404, as expected, but

Continue reading

Restangular getList does not return anything

Issue I am really new with angular and restangular, maybe you can help me, Why does this code work tunariAppApp.controller(‘ProductListCtrl’, function ($scope, Restangular){ Restangular.all(‘products’).getList().then(function(result){ $scope.products= result; }); } ); and this one doesnt???? tunariAppApp.controller(‘ProductListCtrl’, function ($scope, Restangular){ $scope.products = Restangular.all(‘products’).getList();

Continue reading

Angular 2 HTTP post to Web API without [FromBody]

Issue I have a sample Angular 2 code below. this.headers = new Headers({ ‘Content-Type’: ‘application/json’ }); this.options = new RequestOptions({ headers: this.headers }); this.http.post(‘/api/todo/create’, JSON.stringify(todo), this.options); I also have an API action as seen below (ASP.NET Core) [HttpPost] [Route(“create”)] public

Continue reading

What is the better way to add office 365 javascript api library to angular js project?

Issue Officejs library can be used inside angular controller as following way by adding library reference https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js to index page function sendRequest() { // Create a local variable that contains the mailbox. var mailbox = Office.context.mailbox; mailbox.makeEwsRequestAsync(getItemRequest(mailbox.item.itemId), callback); } function

Continue reading

declare one controller for each tab

Issue I’m using tabs in an html page and I’m trying to declare one controller for each tab. <div class=”tab-content”> <div class=”tab-pane active” id=”customerInfo”> @customerList() </div> <div class=”tab-pane” id=”communities”> @communityList() </div> For the first tab I declare my controller in

Continue reading

Getting Response from Restangular POST

Issue How do I get the response object after I send a Restangular POST? firstAccount.post(“Buildings”, myBuilding).then(function() { console.log(“Object saved OK”); }, function() { console.log(“There was an error saving”); }); I’m trying to get the new object id. Thanks. Solution I’m

Continue reading

Deserialize Json Datatype File

Issue I’m trying to deserialize a Json string to a custom class. My json is: externDossierNr:”foo10″ internDossierNr:”2016010″ rapport:File testarray:Array[3] testword:42 __proto__:Object externDossierNr, internDossierNr and rapport are data I get from my form. I can deserialize externDossierNr and internDossierNr. When I

Continue reading

Restangular OneToOne connection

Issue At #/dossiers/{id}/offertes of my client application I need to get my dossier from rest api/dossiers/{id}. Then on that dossier I need to get the corresponding offerte api/dossiers/{id}/offerte From that I will get my offerteRecords api/offertes/{id2}/records I wil include my

Continue reading

Restangular – get root collection

Issue I’m trying to implement Restangular in my SPA application. I have multiple API root addresses. So I created base providers (factories) for each API root, for example: function ApiUsers(Restangular){ return Restangular.withConfig(function(config) { config.setBaseUrl(‘/srv/users’); }); } Where /srv/users returns all

Continue reading

Restangular: long url with params

Issue I’m trying to do such query url: Restangular.one(‘company’).one(‘manager’).one(managerId).get(params) which should be for example: /company/manager/12/?param1=value1&param2=value2 but something went wrong, and i get: Error: You’re creating a Restangular entity with the number instead of the route or the parent. For example,

Continue reading