Uncaught TypeError: $translate is not a function - angular-translate

This is my code:
$translate('singlePointHistory.B').then(function(paragraph{overcrowdedDetail.personNum = paragraph;});
It gives the following error::
Uncaught TypeError: $translate is not a function
Why?

Looks like you are missing a bracket after paragraph . So it would be
function(paragraph) {
vercrowdedDetail.personNum = paragraph;
});
Also, I would try using $translate.instant(key);
Make sure you have injected $translate to your controller.

Related

How to access route object in Vue prototype?

How to access $route object, similar to this.$route, in a custom Vue prototype?
//main.js
Vue.prototype['$notify'] = params => {
//console.log('this', this) undefined
console.log('Vue.prototype', Vue.prototype)
/* console shows among other valid properties:
$route: [Exception: TypeError: Cannot read property '_route' of undefined at Object.get (webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1221:52) at Object.invokeGetter (<anonymous>:2:14)]
$router: [Exception: TypeError: Cannot read property '_router' of undefined at Object.get (webpack-internal:///./node_modules/vue-router/dist
*/
//this throws error: Vue.prototype.$route
}
Arrow function isn't a shortcut for regular function, that it uses lexical this instead of dynamic this is one of the differences.
In case the method should access Vue instance, it should be:
Vue.prototype['$notify'] = function (params) {
console.log(this.$route);
...
};

Cannot read property 'api'

I'm trying to define the columns.
import { GridOptions } from "ag-grid-community";
import "ag-grid-enterprise";
......
private gridOptions:GridOptions;
.....here I fill columdDefs
this.gridOptions.api.setColumnDefs(columnDefs);
but when I execute I get this error.
Unhandled rejection TypeError: Cannot read property 'api' of undefined at HoursDataTable.defineColumns
Any idea please?
Regards
Solved adding this
this.gridOptions = <GridOptions>{};
Thanks

GetMatchingProductSample AMAZON API

Im try to Get Product details with GetMatchingProductSample.php
request param look correctly:
$request->setSellerId(MERCHANT_ID);
$request->setMarketplaceId(my ID);
$request->setASINList(my ASIN);
when i try to execute i receve always this error:
Fatal error: Call to a member function _toQueryParameterArray() on a non-object
I've look a method but i dont see any error
When i type request-> i have only these methods:
setASINlist
setSellerId
setMWSAuthToken
Finally i found a way to do a right call.
Obviously they lacked the parameters and if someone can serve this is the correct call:
$asins = array('B06Y16RL4W', 'B071DQ128D');
$request = new
MarketplaceWebServiceProducts_Model_GetMatchingProductRequest();
$asin_list = new MarketplaceWebServiceProducts_Model_ASINListType();
$request->setSellerId(MERCHANT_ID);
$request->setMarketplaceId(MARKETPLACE_ID);
$asin_list->setASIN($asins);
$request->setASINList($asin_list);

How to fix this error:Uncaught (in promise) TypeError: this.state.arrdata.map is not a function

How to fix this error:
Uncaught (in promise) TypeError: this.state.arrdata.map is not a function
I am learning React and I hope you can help me. Thanks!
OpenWeatherMap's API does not return an array, but an object.
Objects do not have a map() function.
I would suggest using lodash.map because it doesn't care if it's undefined, object or array which could save a lot of trouble.
import _ from 'lodash';
var listItems = _.map(this.state.arrData, (function(item){
... bla bla bla
})

Why do I get undefined when trying to parse POST request with busboy? Using MEAN.IO stack

I am trying to use busboy-connect to parse my request file that I send to the server. When I print out my request object, I get this huge Angular.identity object and when I try and parse the object using this code:
app.post("/compositions/fileUpload", function(req, res){
var fstream;
req.pipe(req.busboy);
req.busboy.on('file', function (fieldname, file, filename) {
console.log("Uploading: " + filename);
fstream = fs.createWriteStream('/files/' + filename);
file.pipe(fstream);
fstream.on('close', function () {
res.redirect('back');
});
});
I error out on the "req.pipe(req.busboy)". I do require connect-busboy, and fs. I also make sure to tell my app to use busboy, so they should be there. However, I continue to get this error:
TypeError: Cannot call method 'on' of undefined
at IncomingMessage.Readable.pipe (_stream_readable.js:476:8)
at Object.handle (/home/cyen/development/composelet/source/composelet/packages/compositions/server/routes/compositions.js:38:10)
at next_layer (/home/cyen/development/composelet/source/composelet/node_modules/express/lib/router/route.js:103:13)
at Route.dispatch (/home/cyen/development/composelet/source/composelet/node_modules/express/lib/router/route.js:107:5)
at /home/cyen/development/composelet/source/composelet/node_modules/express/lib/router/index.js:213:24
at Function.proto.process_params (/home/cyen/development/composelet/source/composelet/node_modules/express/lib/router/index.js:286:12)
at next (/home/cyen/development/composelet/source/composelet/node_modules/express/lib/router/index.js:207:19)
at next (/home/cyen/development/composelet/source/composelet/node_modules/express/lib/router/index.js:182:38)
at next (/home/cyen/development/composelet/source/composelet/node_modules/express/lib/router/index.js:182:38)
at next (/home/cyen/development/composelet/source/composelet/node_modules/express/lib/router/index.js:182:38)
POST /compositions/fileUpload 500 136.347 ms - -
_stream_readable.js:483
dest.end();
^
TypeError: Cannot call method 'end' of undefined
at IncomingMessage.onend (_stream_readable.js:483:10)
at IncomingMessage.g (events.js:180:16)
at IncomingMessage.EventEmitter.emit (events.js:92:17)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)
and I have no idea why. It seems there is another similar question to mine here but it has not been solved yet. Would anyone know what this error could be caused by?
Thanks!
The problem was I did not require(connect-busboy) above my module in the global scope.