Answer the question
In order to leave comments, you need to log in
How to pass data from one template to another?
Hello.
For the first time I’m trying to write an application in Angular myself, and the question is probably simple, but I can’t enter where the dog is buried ((
There is a catalog, by clicking on an element you need to show its detailed page. The transition is done, but I don’t understand how to pull up the data.
There is still a router
angular.module("ShoppingCart", ["ngRoute"])
.controller("catalogListController", function(){
this.catalogItems = arrCatalog;
this.catalogItemsCategories = arrCategories;
})
.config(function($routeProvider){
$routeProvider
.when("/", {
templateUrl: "templates/catalog-index.html"
})
.when("/create", {
templateUrl: "templates/create-index.html"
})
.when("/:id", {
templateUrl: "templates/item-index.html"
})
.otherwise({
redirectTo: "/"
})
})
var arrCatalog = [
{
id: 0,
title: "TV 1",
description: "Some description for TV 1",
price: "$ 13",
image: "upload/tv-1.jpg",
type: {tv: true}
},
{
id: 1,
title: "TV 2",
description: "Some description for TV 2",
price: "$ 23",
image: "upload/tv-2.jpg",
type: {tv: true}
},
<a ng-href="#/{{catalogItem.id}}">
<h1 class="page-header">{{title}}</h1>
<div class="row catalog-inner">
<div class="col-xs-6">
<div class="img-big"><img src="upload/notebook-1.jpg" alt=""></div>
</div>
<div class="col-xs-6">
<div class="price">$ 20</div>
<div class="description">description</div>
<div class="quantity">
<form action="#" class="form-inline clearfix">
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question