Answer the question
In order to leave comments, you need to log in
How to create a site search widget in AngularJS?
there is a layout.php file that defines content and rightSide blocks.
<html ng-app="app">
<body>
<div class=content><div ng-view></div></div>
<div class="rightSide">
<form class="form-inline" role="form">
<div class="input-group">
<input
type="text"
name="query"
class="form-control"
placeholder="<?= $lang->search_place ?>"
value="<?=$this->container->request->query('query')?>"
/>
<span class="input-group-btn">
<button
class="btn btn-info"
ng-controller="SearchCtrl"
ng-click="setSearch(jQuery('input.form-control[mane=query]').val())"
>
<?= $lang->search ?>
</button>
</span>
</div>
</form>
</div>
</body>
</html>
'use strict'
class SearchCtrl
@$inject: [ '$scope', '$location', '$routeParams', 'SearchService' ]
constructor: (@scope, @location, @routeParams, @SearchService) ->
@scope.search_string = @routeParams.query
this.loadingSearch()
loadingSearch: ->
@scope.loadingPromise = @SearchService.getList {q: @scope.search_string}
@scope.loadingPromise.then (data) =>
@scope.elements = data
setSearch: (data) ->
debugger
@location.url '/search?query='+data
angular.module('SearchModule').controller 'SearchCtrl', SearchCtrl
Answer the question
In order to leave comments, you need to log in
It seems to me that you mixed something
1. Give the name of the form
2. Give the model to the input
3 Check using
Angular
<form name ="searchForm">
<input type="text" name="search" ng-model="search.name" placeholder="Поиск" required>
<button type="submit" ng-click="search(searchForm.$valid)">Поиск</button>
код контроллера
....
$scope.search = function(valid) {
if (valid) {
Ваш код
...
}
};
</code
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question