Error with DNN module - dotnetnuke

I have a comments module in my DNN site. I have installed that module on my site successfully but I am not able to work with it. It shows these errors.
Uncaught ReferenceError: ko is not defined
Uncaught TypeError: Cannot call method 'fromJS' of undefined
GEThttp://localhost:1726/resources/shared/scripts/jquery/jquery.min.map 404 (Not Found)
GET http://localhost:1726/jquery.min.map 404 (Not Found)
But I have defined ko in my JavaScript code:
function Comment(data) {
var self = this;
self.CommentId = ko.observable();
self.CommentText = ko.observable();
self.ModuleId = ko.observable();
self.PortalId = ko.observable();
self.updateFromJS = function (data) {
if (data != null && data != undefined)
ko.mapping.fromJS(data, {}, this);
};
self.updateFromJS(data);
};

Related

SyntaxError: Unexpected token in $http.get() request

I tried to make my first Angular app, but faced this error
JS code:
var app = angular.module('sortApp', [])
app.controller('sortController', ['$http', function ($http) {
var sort = this;
sort.orders = [];
$http.get('angular/orders.json').success(function (data) {
sort.orders = data;
});
Error log:
SyntaxError: Unexpected token n in JSON at position 17
at JSON.parse (<anonymous>)
at cc (angular.js:1139)
at Ud.e.defaults.transformResponse (angular.js:7481)
at angular.js:7429
at r (angular.js:325)
at xc (angular.js:7428)
at b (angular.js:8122)
at L (angular.js:11561)
at angular.js:11647
at k.$eval (angular.js:12673)
what could cause it?
your json is invalid format. Check it first.

Uncaught TypeError: undefined is not a function Android Browser

I am getting a strange error on Android Browser that it constantly says
Uncaught TypeError: undefined is not a function
On a function that is working perfectly on all other browsers even Safari. The website loads everything perfectly on all the browsers, on computer as well as mobiles but when it is viewed on Android browser it throws off that error. I have checked it over all and jquery is included only once. I can post the code here but I dont think it would be of much help because at the start it was giving above mentioned error on a function which i tried to resolve. After that it started giving the same error on another function and it is carrying on like this.
Here is a reference
$.ajax({
type: "POST",
url: XXXXXXXXXXX,
data: dataObj,
cache: false,
success: function (resp) {
if (resp.startsWith("Error:")) {
console.log(resp)
}
else
{
clusters.clearLayers();
// common.clearLayers();
var result = JSON.parse(resp)
console.log(result.user);
if (result.user == 'free')
{
makeFreePokemon(result[0]['hits']['hits'])
}
else
{
makePokemon(result[0]['hits']['hits'])
}
// if (result[0]['hits']['total'] > 1000) {
// window.setTimeout(search(),500)
// }
}
}
})
In the above code it gives the undefined error ON
if (resp.startsWith("Error:")) {
When I solve this, it starts giving the same error another location.
Anyhelp would be really great.
Thanks

angular.js - Uncaught TypeError: Cannot call method 'replace' of undefined

I created an angular app with yeoman via the angular-fullstack generator.
Now I'm trying to run the client part of the app on an android device via phonegap.
I get the error:
Uncaught TypeError: Cannot call method 'replace' of undefined angular.js:4407
This is the part of the angular.js file that produces this error:
////////////////////////////////////
// internal Injector
////////////////////////////////////
function createInternalInjector(cache, factory) {
function getService(serviceName, caller) {
if (cache.hasOwnProperty(serviceName)) {
if (cache[serviceName] === INSTANTIATING) {
throw $injectorMinErr('cdep', 'Circular dependency found: {0}',
serviceName + ' <- ' + path.join(' <- '));
}
return cache[serviceName];
} else {
try {
path.unshift(serviceName);
cache[serviceName] = INSTANTIATING;
return cache[serviceName] = factory(serviceName, caller);
} catch (err) {
console.log(err);
if (cache[serviceName] === INSTANTIATING) {
delete cache[serviceName];
}
throw err;
} finally {
path.shift();
}
}
}
...
I have a hard time debugging this since the error occurs only on the android device. In the browser it works fine.

trouble with angular and flask - error message vauge

Not able to get angular to read in an object fetched via service. Error message in brower is really vauge, doesn't reference any of my code lines. I checked via Chrome Developer tools and the api call is getting made. Any ideas?
Error message:
TypeError: undefined is not a function
at copy (http://127.0.0.1:5000/static/lib/angular/angular.js:593:21)
at http://127.0.0.1:5000/static/lib/angular/angular-resource.js:410:19
at wrappedCallback (http://127.0.0.1:5000/static/lib/angular/angular.js:6846:59)
at http://127.0.0.1:5000/static/lib/angular/angular.js:6883:26
at Object.Scope.$eval (http://127.0.0.1:5000/static/lib/angular/angular.js:8057:28)
at Object.Scope.$digest (http://127.0.0.1:5000/static/lib/angular/angular.js:7922:25)
at Object.Scope.$apply (http://127.0.0.1:5000/static/lib/angular/angular.js:8143:24)
at done (http://127.0.0.1:5000/static/lib/angular/angular.js:9170:20)
at completeRequest (http://127.0.0.1:5000/static/lib/angular/angular.js:9333:7)
at XMLHttpRequest.xhr.onreadystatechange (http://127.0.0.1:5000/static/lib/angular/angular.js:9303:11)
Service:
angular.module('angularFlaskServices', ['ngResource'])
.factory('Pic', function($resource) {
return $resource('/api/pic/:picId', {}, {
query: {
method: 'GET',
params: { picId: '' },
isArray: true
}
});
})
;
Angular Controller:
function ProfileController($scope, Pic) {
var picsQuery = Pic.get(function(pics) {
$scope.pics = pics;
});
}
Flask View:
#app.route('/api/pic/')
def on_recent():
if not session.has_key('access_token'):
return 'Missing Access Token'
try:
api = client.InstagramAPI(access_token=session['access_token'])
recent_media, next = api.user_recent_media()
print recent_media
photos = []
for media in recent_media:
if (media.type != "video"):
photos.append({"picId": 1, "url": media.get_low_resolution_url()})
except Exception as e:
print(e)
return json.dumps(photos)
Your service code looks good but I am not sure if you have all of your dependencies injected properly.
var app = angular.module('myApp', ['angularFlaskServices']);
app.controller('ProfileController', [
'$scope',
'Pic',
function($scope, Pic) {
var picsQuery = Pic.get(function(pics) {
$scope.pics = pics;
});
}]);

AngularJS set header on every request

I'm trying to set a header to send an access token on every request. This is what I have tried:
.factory("TokenRestangular", "StorageService", function (Restangular, StorageService) {
return Restangular.withConfig(function (RestangularConfigurer) {
// Set access token in header.
RestangularConfigurer.setDefaultHeaders({Authorization:'Bearer '+ StorageService.get("access_token")});
RestangularConfigurer.setBaseUrl('/api');
});
})
I get the error:
Error: [ng:areq] http://errors.angularjs.org/1.2.19/ng/areq?p0=fn&p1=not%20aNaNunction%2C%20got%string
at Error (native)
at http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js:6:450
at Bb (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js:19:68)
at Ua (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js:19:155)
at rc (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js:32:423)
at Object.d [as invoke] (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js:34:398)
at http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js:36:288
at c (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js:34:305)
at d (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js:35:6)
at Object.instantiate (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js:35:165)
I think your factory function has one too many parameter passed, try this:
.factory("TokenRestangular", function (Restangular, StorageService) {
return Restangular.withConfig(function (RestangularConfigurer) {
// Set access token in header.
RestangularConfigurer.setDefaultHeaders({Authorization:'Bearer '+ StorageService.get("access_token")});
RestangularConfigurer.setBaseUrl('/api');
});
})
or
.factory("TokenRestangular", ["Restangular", "StorageService", function (Restangular, StorageService) {
return Restangular.withConfig(function (RestangularConfigurer) {
// Set access token in header.
RestangularConfigurer.setDefaultHeaders({Authorization:'Bearer '+ StorageService.get("access_token")});
RestangularConfigurer.setBaseUrl('/api');
});
}])
if you want to have safe minification code.

Resources