0
I’m making a very basic forum where the user type the title, subject and theme description, and this is sent to Mongo (I’m also using Postman), with the help of the people from here on another topic, this part is already finished. In the index appears all the registered topics and a button to access to view a given topic, ie each topic has an id. The question is: how to display each item of a given id? Below I have already done, with the help of some users here:
Note: _id is the topic code
function ListaTopicosController($scope, $http) {
...
var myApp = angular.module('myApp',[]);
myApp.controller('forumList', ['$scope', '$http', function($scope, $http) {
$scope.carregarDados = function() {
var url = 'http://localhost:3000/topico/lista'
$http.get(url, {id: $scope.data._id}).then(
function successCallback(resposta) {
$scope.forum.titulo = resposta.data.titulo;
},
function errorCallback(resposta) {
}
);
}
}]);
<body ng-app="myApp" ng-controller="ListaTopicosController" >
<div class="jumbotron text-center">
<h1><font color="#00c6d7">ALLDISPOR</font></h1>
<p>Fórum de Discussão</p>
</div>
<div class="container">
<div class="row">
<div ng-controller="forumList" ng-init="carregarDados()">
<h2>{{ forum.titulo }}</h2>
<h4> {{ forum.assunto }}</h4>
</div>
To answer your question I need some more information. First, could you give an example of how the topics are organized in the database? This can be done with db. <collection_name>. findOne()
– Daniel Reis
Second, you could display the URL code you are sending GET request (http://localhost:3000/topic/list)?
– Daniel Reis