AngularJS: Condition to show a single value with ng-bind or multiple values ​​with ng-repeat?

Hi all,

I asked a question about Stack Overflow regarding AngularJS and a site I'm working on, but I could not get anyone to answer my second question. Is there any way to indicate to Angular, through a condition or anything else, that it obtains a single value / row with ng-bind if a parameter is used or that it obtains multiple values ​​/ rows with ng-repetition if a parameter does not it's used?

Here is my routing configuration / AngularJS driver:

Code:

var app = angular.module ("testApp", ["ngRoute"]);
app.config (['$routeProvider','$locationProvider',
function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider
	.when("/", {
		templateUrl : "home.php"
	}).when("/home", {
		redirectTo : "/"
	}).when("/news", {
		templateUrl : "news.php"
	}).when("/newspost/:id", {
		templateUrl : "newspost.php",
		controller: "newsList"
	}).otherwise({
		redirectTo : "/"
	});
}]);
app.controller ("newsList", function ($ scope, $ http, $ routeParams) {
ID of var = $ routeParams.id;
$ http.get ("newsitem.php? id =" + id)
.then (function (resp) {
$ scope.item = resp.data;
});
});
app.filter (& # 39; not safe & # 39 ;, function ($ sce) {
return function (val) {
returns $ sce.trustAsHtml (val);
};
});

As you can see, when you visit / news, "news.php" is loaded, which simply takes all the elements of "news" and lists them through simple PHP (there are no angular directives on this page).

When you visit / newspost / #, you will use "newsitem.php" to get the data and show everything through "newspost.php" with the Angular directives.

Here is my configuration "newsitem.php":

PHP Code:


<? php

demand(& # 39; config2.php & # 39;);

$ id = $ _GETThe[["I.D"];

$ newsQuery = $ dbh->prepare("SELECT * FROM news WHERE id =: id LIMIT 1");

$ newsQuery->run(training(":I.D"=>$ id));

$ newsQueryData = $ newsQuery->has been able to recover(DOP::FETCH_ASSOC);

echo
json_encode($ newsQueryData);

?>

Here is my configuration of "newspost.php":

PHP Code:


<div class ="row">

<
div class ="col-md-12">

<
div class ="panel-default panel-custom">

<
div class ="panel header">

<
h3 class ="panel title"> <I class ="fa fa-lg fa-newspaper-o" aria-hidden="true"> </I> News</h3>

</
div>

<
div class ="panel-body">

<
div ng-controller="news list">

<
div>

<
img src="asset / images / news.png" alt="News" class ="img-center img-sensible">

<
br>

<
a href="https://twitter.com/share?url=https://sitename.com/newspost/{{item.id}}&text= Take a look at this news article!" class ="btn btn-info" objective="_White">cheep</a>

<
br>

<
br>

<
div ng-link-html="item.article | unsafe"> </div>

</
div>

</
div>

</
div>

</
div>

</
div>

</
div>



Is there a way to have everything routed to / news or / news / #, and if the # parameter is not used, it will extract all the "news" and show everything in "news.php" with ng-repeat, it will only show the specific "news" element with ng-bind if the # parameter is used?