I have a site using Laravel 5 / AngularJS
I kept getting
Uncaught Error: [$injector:modulerr]
I don't even know where to begin.
I've tried random things like looking at my includes for links and scripts, and how I declare and include my AngularJS. I don't really spot anything.
This is what I have so far
<script type="text/javascript">
myApp.controller('weddingController', function weddingController($scope,$log,$http) {
$scope.guestNum = 1;
$scope.going = 1;
$scope.email = /^[_a-z0-9]+(\.[_a-z0-9]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/;
$scope.notify = function (message, type){
$.growl({
message: message
},{
type: type,
allow_dismiss: false,
label: 'Cancel',
className: 'btn-xs btn-inverse',
placement: {
from: 'top',
align: 'right'
},
delay: 2500,
animate: {
enter: 'animated bounceIn',
exit: 'animated bounceOut'
},
offset: {
x: 20,
y: 85
}
});
};
// ---------------------------------------------------------
$scope.rsvp = function() {
// RSVP
var $inputs = {};
$inputs.name = $('#rsvp-form #name').val();
$inputs.email = $('#rsvp-form #email').val();
$inputs.message = $('#rsvp-form #message').val();
$inputs.going = $scope.going;
$inputs.guestNum = $('#rsvp-form #guestNum').val();
$('.loading').removeClass('hidden');
var ajax = $.ajax({
headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('value')},
url: '/wedding/rsvp',
type: 'POST',
data: $inputs
});
ajax.done(function (data) {
var audio = document.getElementById("myAudioTagID");
audio.play();
$('#rsvp-form').find("input[type=text],input[type=email], textarea").val("");
// $('#rsvp-form label').hide();
$('.loading').addClass('hidden');
$('#thankModal').modal('show');
$('#thankModal #text').text('Thanks for your response !');
setTimeout(function() {$('#thankModal').modal('hide');}, 3000);
});
};
$scope.addNote = function() {
$('#lv-avatar').addClass('hidden');
$('#name').on('keyup', function() {
if($(this).val().trim().length !== 0){
$('#lv-avatar').removeClass('hidden');
$('#lv-avatar').fadeIn();
$('#lv-avatar').text($(this).val()[0]);
}else{
$('#lv-avatar').addClass('hidden');
}
});
};
$scope.note = function() {
// RSVP
var $inputs = {};
$inputs.name = $('#guest_note #name').val();
$inputs.message = $('#guest_note #message').val();
$('.loading').removeClass('hidden');
var ajax = $.ajax({
headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('value')},
url: '/wedding/note',
type: 'POST',
data: $inputs
});
ajax.done(function (data) {
var audio = document.getElementById("myAudioTagID");
audio.play();
$('#closeMyModal').click();
setTimeout(function() {$('#guestNoteModal').modal('hide');}, 1000);
$('#guest_note').find("input[type=text], textarea").val("");
$('#guest_note label').hide();
$('.loading').addClass('hidden');
$('#thankModal').modal('show');
if(''){
setTimeout(function() {$('#thankModal').modal('hide');}, 3000);
}else{
setTimeout(function() {$('#thankModal').modal('hide');}, 5000);
}
$("#home").click();
});
};
$scope.nav = {};
$scope.nav.showMenu = false;
console.log($scope.nav.showMenu);
$scope.showMenu = function() {
$scope.nav.showMenu = true;
// $('body').addClass('stop-scrolling');
// $('body').bind('touchmove', function(e){e.preventDefault()});
};
$scope.hideMenu = function() {
$scope.nav.showMenu = false;
// $('body').removeClass('stop-scrolling');
// $('body').unbind('touchmove', function(e){e.preventDefault()});
};
});
</script>
app.js
"use strict";
var myApp = angular.module('myApp', ['ui','ngTagsInput','ckeditor','color.picker'], function($interpolateProvider,$httpProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
//Setting headers
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
$httpProvider.defaults.headers.common['X-Requested-With'] = "XMLHttpRequest";
$httpProvider.defaults.headers.post['X-CSRF-TOKEN'] = $('meta[name=_token]').attr('content');
});
I am not sure if the issue is in the Controller or somewhere else outside of my controller.
Any hints on this will be much appreciated!
Note : I looked through a lot of answers with this similar error but everyone seems to have different situation.
Here is my live site that have this issue :(
https://www.bunlongheng.com/wedding
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire