Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:

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

share|improve this question
1  
So I can inspect element on your page and get your sql code which will give me an idea about your table and it makes it easier for me to attack. This is really a bad idea. – ODelibalta Oct 21 at 14:24
    
Well, i have to do it like this... I know that it isn't a good idea... but its simply to retrieve few lines from the database... Even though, I would really like to know how I can effectively access these elements – Fischer Oct 21 at 14:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.