I'm relatively new to AJS
I have to save a SQL Statement inside an html input for easy maintanance but cant seem to access it properly like the examples I've seen everyhwere
My routeconfiguration is created with Ionic
.state('main.article', {
url: 'main/article',
views: {
'menuContent': {
templateUrl: 'templates/article.html',
controller: 'ArticleCtrl'
}
}
})
My controller
.controller("ArticleCtrl", function($scope, $http, $state){
$scope.article_json = function() {
$scope.sql_search_string = (typeof this.query === 'undefined')? '' : this.query; //$scope.query doesn't work
var request = $http({ //retrieves data from odbc which is shown under the searchinput
Directive for ngEnter
.directive('ngEnter', function () {
return function (scope, element, attrs) {
element.bind("keydown keypress", function (event) {
if(event.which === 13) {
ionic.debounce(scope.$apply(function (){
scope.$eval(attrs.ngEnter);
event.target.blur();
}), 500);
event.preventDefault();
}
});
}
})
<label class="item item-input item-floating-label">
<span class="input-label">Volltextsuche:</span>
<div class="row bar-tabs"><i class="icon ion-search bar-tabs placeholder-icon"></i>
<input ng-enter="artcle_json()" ng-model="query" type="text" sql-code="SELECT ... ">
</div>
Well, i have several issues 1) No matter what I've tried in my ArticleCtrl inside the article_json function its not possitble to access the input-value via "$scope.query"... only this.query has worked before..
2) more importantly: I need a way to access the input Html attribute: "sql-code" without using "document.getElementById().getAttribute()"...
Somehow access it with $scope or something.. also using another html-element would be fine... I just need to access it..
Probably a directive is the way to do it... and somehow giving it to the controller, but I dont know how my directive needs to look like
..later on I want to "globalize" everything into a mainservice for all sql queries
Well that's it for now, I hope with some help I can contine my work
If you need more details just ask