Unknown provider error in AngularJS - asp.net

Now I am working on a project using Asp.Net MVC + AngularJS. Everything go well in development, but when I run it on IIS, an error occurs:
Uncaught Error: [$injector:unpr] Unknown provider: nProvider <- n
How can I locate the nProvider? How can I fix this error?
Screenshots of my errors:

try reading the answer to this post and see if it helps you.
You should be able to see the component's name in the function hopefully. a bit poor but better than nothing. let's hope angular 2.0 is a little more helpful.
Finding the cause of "Unknown provider" errors

Thanks above all. It's really a minification problem. I'v found the solution, please refer the following codes, the italic codes are added to fix the problem.
Change
var app = angular.module('app', [
'ui.router',
'...'
])
.run(function ($templateCache, $http) {
$http.get('tpl.path')
.then(function(response) {
// ...
});
});
To
var app = angular.module('app', [
'ui.router',
'...'
])
.run(['$templateCache', '$http', function ($templateCache, $http) {
$http.get('tpl.path')
.then(function(response) {
// ...
});
}]);

Related

Meteor Iron Router - no route definitions after Meteor v2.6 upgrade?

I've just upgraded my project to Meteor v2.6 along with all packages. Everything runs smoothly on local so I pushed to Galaxy where I'm promptly met by this error when trying to load my app:
Nothing in the codebase itself was changed, needless to say the routes have been defined and have been working fine before.
Here's an excerpt of the code:
import "/imports/ui/layouts/dashboardLayout/dashboardLayout";
import "/imports/ui/layouts/landingLayout/landingLayout";
import "/imports/ui/pages";
import "/imports/ui/pages/landing/landingHeader/landingHeader";
if (Meteor.isClient && Meteor.isProduction) {
Router.plugin("reywood:iron-router-ga");
}
Router.configure({
trackPageView: true,
});
Router.onAfterAction(() => {
window.scrollTo(0, 0);
});
Router.route("/", {
name: "landing",
layoutTemplate: "landingLayout",
action: function () {
this.render("landingHeader", { to: "header" });
this.render("landingContent", {
to: "content",
data: { signUp: !!this.params.query.signUp },
});
},
});
Below the diff in the versions file>
Given it runs fine locally but has issues in Production, I wonder whether the problem is this bit of code here:
if (Meteor.isClient && Meteor.isProduction) {
Router.plugin("reywood:iron-router-ga");
}
I don't know why it's there (it's not my code originally) but I've noticed that the reywood:iron-router-ga version seems to have been downgraded for some reason during the upgrade:
When I try to force an update to reywood:iron-router-ga in the vain hope that by getting it back to v2.0.1 it will start working again, I get the message that "The specified packages are at their latest compatible versions".
Has anyone encountered this before/any idea what's going on? I'm not a fan of forcing different behaviour in Production from Dev as that obviously makes testing difficult/pointless - unless there's a good reason for it. Can anyone shed any light?

How to fix ( $ is not a function ) for gulp building js file?

I got an error: Uncaught TypeError: $ is not a function at app.min.js?ver=5.6.2:1 I know there are many answers to this question. But not in my case. For developing a theme, I am using gulp. So the app.min.js The file is constantly changing during development and I can't just add:
jQuery(document).ready(function($) {
});
If we were talking about a finished project, it always helps me. But not at this time. Here is part of my gulp file who is responsible for creating: app.min.js
function scripts() {
return src([
'../themes/themename/js/vendor/ajax-mail.js',
'../themes/themename/js/vendor/bootstrap.min.js',
'../themes/themename/js/vendor/imagesloaded.pkgd.min.js',
'../themes/themename/js/vendor/isotope.pkgd.min.js',
'../themes/themename/js/vendor/jquery.counterup.min.js',
'../themes/themename/js/vendor/jquery.magnific-popup.min.js',
'../themes/themename/js/vendor/owl.carousel.min.js',
'../themes/themename/js/vendor/plugins.js',
'../themes/themename/js/vendor/popper.js',
'../themes/themename/js/vendor/waypoints.min.js',
'../themes/themename/js/app.js',
])
.pipe(concat('app.min.js'))
.pipe(uglify())
.pipe(dest('../themes/themename/js'))
.pipe(browserSync.stream())
}
Maybe there is some way to automatically frame all content of the app.min.js in
jQuery(document).ready(function($) {
});
I cannot find a solution, I will be glad for the help. Thanks!

jPlayer 2.6.0 not playing audio throwing no supported source found error

I am using jQuery jPlayer for audio files in my project. Earlier it was just fine but now all of a sudden it's just not working but throwing errors as:
GET http://traffic.libsyn.com/vemsagenda/vemsagenda0.mp3 net::ERR_EMPTY_RESPONSE
Uncaught (in promise) DOMException: Failed to load because no supported source was found.
jPlayer 2.9.2 : id='jquery_jplayer_1' : Error!
It is not possible to play any media format provided in setMedia() on this browser using your current options.
Video or audio formats defined in the supplied option are missing.
Context: {supplied:'mp3'}
I am not getting idea as what is wrong all of a sudden. It was working just fine.
jsfiddle: https://jsfiddle.net/bxwkyhsb/12/
Code:
$('#jquery_jplayer_1').jPlayer({
ready: function () {
$(this).jPlayer('setMedia', {
mp3: '".$audio_link[$i]."'
});
},
play: function() { // To avoid multiple jPlayers playing together.
$(this).jPlayer('pauseOthers');
equal_height_pod();
},
swfPath: 'js',
supplied: 'mp3',
wmode: 'window',
globalVolume: true,
smoothPlayBar: true,
keyEnabled: true,
preload: 'none',
errorAlerts: true,
warningAlerts: true
});
$('#jquery_jplayer_1').bind($.jPlayer.event.play, function() {
$('.jp-audio').removeClass('showcontainer').parent('figure').parent('.leftImg').parent('li').removeClass('titlewrap');
$('#jp_container_1').addClass('showcontainer').parent('figure').next('.introtitle').addClass('wrapintrotitle');
$('#jp_container_1').parent('figure').parent('.leftImg ').parent('li').addClass('titlewrap');
});
Any help/suggestions are welcome. Thanks in advance.
supplied: 'mp3'. Try that. It's missing in your example.
The code is working just fine. As #Martin Mazza Dawson said it's due to network problem(firewall). You can play it using chrome extension 'Browsec'.

meteor this.params._id is undefined stick

I'm a student learning meteor.js.
iron:router is using:
this.route('postEdit', {
path: '/posts/:_id/edit',
data: function() {
console.log(this.params._id);
return Posts.findOne(this.params._id); }
});
And this error is displayed:
this.params._id value is undefined76kndYuWd2KDX2eeE...
Why does undefined has that stick value?
postEdit call has:
Edit
Originally, it was 76kndYuWd2KDX2eeE due to URL being localhost:3000/posts/undefined76kndYuWd2KDX2eeE/edit...
Please, help me. Thank you.
Please update to iron#1.0.9, that should fix it.
Apparently this is a problem with iron:router#1.0.8, just run meteor update again and it will automatically update to the latest version of iron:router which solves this problem.
https://github.com/iron-meteor/iron-router/issues/1359

KARMA Reference error:angular is not defined

I have a asp.net mvc app . In Scripts I have the subfolder app containing Controller.js. I also have another subfolder Spec containint ControllerSpec.js - written with jasmine.
describe('PhoneCat controllers', function () {
beforeEach(module('phonecatApp'));
describe('PhoneListCtrl', function () {
it('should create "phones" model with 3 phones', inject(function ($controller) {
var scope = {},
ctrl = $controller('PhoneListCtrl', { $scope: scope });
expect(scope.phones.length).toBe(3);
}));
});
});
In SpecRunner.cshtml i have just included this files:
<script type="text/javascript" src="/Scripts/app/controllers.js"></script>
<script type="text/javascript" src="/Scripts/Spec/controllersSpec.js"></script>
In karma init, I have added the path of those 2.js.
Can you please tell me how can I do to make it work? If I run vs the Jasmine code it's ok.
Thx
You must add a reference to angular.js as well
There could be a variety of reasons for such an error, so it would help to solve with a bit more info on your part.
However off hand and having seen this error before in my battles through angular unit testing, I have to ask are you including a link to angular-mocks.js?
The lastest repo: http://code.angularjs.org/1.2.15/
Angular Mocks: http://code.angularjs.org/1.2.15/angular-mocks.js
A copy of your karma.conf.js would also help....

Resources