I'm using angularTemplatecache with gulp to put all my HTML in a templates.js file but I keep getting an error and cant seem to get it to work.
Uncaught ReferenceError: module is not defined
This error seems to be originating from templates that have ng-include in them because if I remove them from the templates.js file and load them normally it works. Here is one template that is giving me problems
<div class="box-flight-search" ng-show="showNewFlightSearch">
<flight-search-options fn-flight-search="onFlightSearch"
city-airport-data="citiesAndAirportsData"
airv-data="airvsData"
ptc-data="ptcData"
fare-class-data="fareClassData"></flight-search-options>
</div>
<div class="box-flight-search" ng-show="showLastPnr && showNewFlightSearch">
<ng-include src="'app/dashboard/views/dashboard.last.pnrs.html'" />
</div>
<div class="container-fluid" ng-if="!showNewFlightSearch">
<div class="row">
<!-- ng-hide="showNewFlightSearch" -->
<div class="main-search-wrapper">
<div class="inner animated">
<uib-tabset active="0">
<uib-tab index="0">
<uib-tab-heading class="lead">
<i class="glyphicon glyphicon-plane"></i> {{::resource.fields.Fields.FLIGHT_SEARCH}}
</uib-tab-heading>
<br />
<ng-include src="getTemplate('flightSearch')"></ng-include>
</uib-tab>
</uib-tabset>
</div>
</div>
</div>
<div class="row" ng-show="viewLastPnr">
<ng-include src="'app/dashboard/views/dashboard.last.pnrs.html'"
ng-controller="DashboardLastPnrController"
ng-init="onInit(false)" />
</div>
</div>
The getTemplate function i something like this
$scope.getTemplate = function (template) {
switch (template) {
case "flightSearch":
return $scope.viewsPath + "views/dashboard.search_NXG.html";
case "lastPnr":
return $scope.viewsPath + "views/dashboard.last.pnrs.html";
case "queues":
return $scope.viewsQueues + "views/queues.component.html";
}
};
any ideia on how to resolve this?
EDIT: here is my template.js. the file has more but i just removed for simplicity
angular.module("AppRoot").run(["$templateCache",function($templateCache){
$templateCache.put("footer.html",'html here'),
$templateCache.put("app/dashboard/views/dashboard.last.pnrs.html",'html here),
$templateCache.put("app/dashboard/views/dashboard.retrieve.reservation.html",'html here')}]);
AppRoot is the root module for the application
Related
I've made a blog template but I having trouble making the routes. When I click on the link, it should redirect me to the article page. Instead it just redirects me to the same page/same exact location.
Here's my code:
<section id="about" class="ts-block" >
<div id="cards_landscape_wrap-2">
<div class="container">
<div class="row">
#foreach($blogs as $blog)
<div class="col-lg-4">
<a href={{route("blogs.show",$blog->slug)}}>
<div class="card-flyer" >
<div class="text-box">
<div class="image-box ">
<img src="{{'/images/blogs/'.$blog->image}}" alt="{{$blog->title}}" class="img-fluid rounded mx-auto d-block" width="100%"/>
</div>
<div class="text-container">
<h6>{{$blog->title}}</h6>
<p style="max-width: 18rem;"class="ts-opacity__50">{{Str::limit($blog->description,100)}}</p>
</div>
<div class="card-footer">
<span class="text-primary font-weight-bold">Read</span>
</div>
</div>
</div>
</a>
</div>
#endforeach
</div>
</div>
</div>
</section>
BlogController :
public function getArticles()
{
return view('blog')->with([
'blogs' => Blog::all(),
]);
}
Routes :
Route::get('/blog/', [App\Http\Controllers\BlogController::class, 'index'])->name('blog');
Route::get('blogs/','App\Http\Controllers\BlogController#getArticles')->name('blogs.show');
Route::get('/admin/blog', 'App\Http\Controllers\BlogController#getBlog')->name('admin.blog');
Route::resource('/blog','App\Http\Controllers\BlogController');
The routes that supposed to be redirecting me to another page is the 2nd one with BlogController#getArticles. The other routes are fine a have no problem.
Can someone kindly show me what I did wrong ?
Well your question is little confusing, because that's the expected result from the code.
You are calling the 'blogs.show' route, which redirects you to the blogs page. If you want to create a seperate page for every article, you can use Dynamic Rounting in laravel.
All you have to do is:
in web.php:
Route::get('blogs/{slug}', 'App\Http\Controllers\BlogController#getArticle')->name('article.show');
and in your controller:
public function getArticles($slug)
{
$article = Blog::where('slug', $slug)->first();
return view('article')->with([
'article' => $article,
]);
}
After that, <a href={{route("article.show",$blog->slug)}}></a> will work.
First, change your route by :
Route::get('/blogs/{slug}','App\Http\Controllers\BlogController#getArticles')->name('blogs.show');
Then, in your function :
public function getArticles($slug)
{
return view('blog')->with([
'blogs' => Blog::firstWhere('slug', $slug);
]);
}
I cloned a Laravel project off GitHub and navigated to a page which is for a cancellation policy. This is the code inside that file:
#extends('layouts.app')
#section('title', 'Cancellation Policies |')
#section('description', '')
#section('keywords', '')
#section('content')
<section id="section1" class="inr-bnr-sec">
<div class="container">
<div class="section-title1 center-align">
<h1><span>Cancellation Policies</span></h1>
<div>
<ul class="banr-breadcrumb">
<li>Home</li>
<li>Cancellation Policies</li>
</ul>
</div>
</div>
</div>
</section>
<section class="privcy-sec">
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="prvcy-mn-cont">
{!! $page->meta_description !!}
</div>
</div>
</div>
</div>
</section>
#endsection
However on the webpage there is a load of text showing. Where the {!! $page->meta_description !!} statement is, I am assuming this is where the text is located yet I do not know where this code is, nor can I find the file where the code is.
Controller:
public function cancellation_policies(){
$common_model = new Common();
$page = $common_model->getfirst('pages',array( 'id' => '3'));
return view('cancellation_policy')->with('page',$page);
}
Any ideas?
OKay so your $page var is a Common() model
This corresponds with a table, there is probably a column name meta_description in that table.
If not there may be a method called getMetDescriptionAttribute on the model.
Maybe this gets your further?
I'm having an issue with the phonegap ported versions of my app on several devices. On some devices the error (alert) is: "missing ) after argument list", while on other devices "Unexpected token =>".
{ <div class="container home-menu">
<div class="row content-1">
<div class="col-xs-12 text-center">
<!-- Menu -->
<img style="height:90px;" src="res/images/splash_logo.png"/><br>
(unless: (saved-games:) contains $_autosave_slot and (datavalues: (saved-
games:)) contains $_autosave_filename)[(goto: $_start_passage)]
}''<span class="home-button">[[New->$_start_passage]]</span><br>
<span class="home-button">(link: "Continue")[(load-game: $_autosave_slot)]
</span>''<br><a href="#" onClick="closeMeNow();" class="home-
button">Exit</a>
<!-- Credits -->
<div class="bottom-links"><a href="contact.html"><span style="color:
white;">some text</span></a><br>
<span style="color: white;">some text</span></div>
</div>
</div>
</div>
<script> function closeMeNow() { navigator.app.exitApp();} </script>
I fixed it by addding my other JS code to the generated .html file or as an external source, rather than directly into engine I worked with.
I have the following snippet of code,
<div ng-controller="GraphCtrl" ng-if="errorTracerouteResultsLength!=0">
<h5>Erroneous Traceroute Paths
<small>Sub-heading</small>
</h5>
<a href="#" ng-repeat="(key, val) in errorTracerouteResults" ng-click="loadTraceroutePath(val.metadata);">
S: {{val.source.ip}}
D: {{val.destination.ip}}
</a>
</div>
It works fine, loadTraceroutePath belongs to another controller,(lets call it X) but somehow ng-click works and console.log gets printed out with the correct metadata value.
However, in controller X, I have,
$scope.loadIndividualTraceroutePath = function (metadataKey) {
$scope.noOfResults = 1;
}
In the html, I have {{noOfResults}} all over the place. Some of it are able to display 1 while some can't. I have already attached the ng-controller directives and point to controller X, but {{noOfResults}} does not display.
How can I make {{noOfResults}} display in any section of the HTML?
Edit: I have added the HTML.
<div class="row">
<div class="col-lg-9">
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-bar-chart-o fa-fw"></i> Visualisation
<div class="pull-right">
Layout
</div>
</div>
<!-- /.panel-heading -->
<div class="panel-body">
<div class="container" ng-controller="X">
<!--This does not work-->
{{noOfResults}}
</div>
<div>
<div ng-controller="IndividualTraceroutePathGraphCtrl" id="individual_traceroute_path_graph"></div>
</div>
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel -->
</div>
The ng click in the first part of this question is way below.
You have a extra ; at the end, also you are not using the object what you are passing as a parameter to the function, hence Change
From:
<a href="#" ng-repeat="(key, val) in errorTracerouteResults" ng-click="loadTraceroutePath(val.metadata);">
To:
<a href="#" ng-repeat="(key, val) in errorTracerouteResults" ng-click="loadTraceroutePath(val)">
Then,
$scope.loadIndividualTraceroutePath = function (metadataKey) {
$scope.noOfResults = 1;
}
EDIT
You don't need to mention so many controllers in the view, have one controller where the function is defined and remove the rest, here, Update like this,
<div class="container" >
<!--This does not work-->
{{noOfResults}}
</div>
<div>
<div id="individual_traceroute_path_graph"></div>
</div>
</div>
I am trying to Set a default DP for the users who do not have/not uploded an image.
Tried using helpers to display content but getting error "Uncaught Error: {{#each}} currently only accepts arrays, cursors or falsey values."
Code Below(Client JS)
JS :
Template.mcomments.helpers({
'mcommentsdata':function(){
return comdata.find({},{sort:{"at":-1}}).fetch();
},
images2: function () {
var fetchimg=Meteor.users.findOne({
"_id":this.__id
});
if((fetchimg.profileimage==undefined)||(fetchimg.profileimage=="")){
var hello="/images/prof.jpg"
return hello;
}else{
return Images.find({"_id":fetchimg.profileimage})
}
}
});
HTML
<template name="mcomments">
<div id="mcomments" class="col-lg-3">
<div><h5 class="mcommentsheader">Followup Stream </h5>
</div>
<div class="col-lg-12 scrolling comscrolllist" id="mcomments1">
<div id="mcomments2">
{{#each mcommentsdata}}
<div class="col-lg-12 comcontainer">
<div class="row">
<div class="col-lg-3 indcomments" >
{{#each images2}}
<img src="{{this.url
}}" width="45px" height="50px" alt="">
{{/each}}
</div>
<div class="col-lg-9" style="">
<div class="row combody" >
<div class="pull-left mcommfont" >{{user}}</div>
<div class="pull-right mcommcust">{{product}} Case#{{productcaseno}}</div>
</div>
<div class="maincomment">{{comment}}</div>
<div class="comtemp"> <span data-livestamp="{{at}}"></span></div>
</div>
</div>
</div>
<div class="col-lg-12 comblankspace">
</div>
{{/each}}
</div>
</div>
</div>
</template>
Now i have given up on this approach and thinking of uploading an image and attaching the url to all profiles by default(onCreateuser) until they change it.I believe to do this i might have to upload and image automatically on server startup. Please lead me to the right direction as i am still noob in meteor.
Storage Adapter: GridFS.
Regards,
Azaruddin
Change the 'hello' variable to the following code:
var hello = [
{ url: "/images/prof.jpg" }
];
You're running into problems because hello is currently a string - #each expects an array/cursor/etc. as your error suggests.
Alternatively, you could use {{#else}} on your each block and get rid of returning your 'hello' case entirely:
{{#each images}}
...
{{else}}
<!-- Default profile image code -->
{{/each}}