Jackson
Posts: 9
Joined: Wed Nov 01, 2017 10:44 pm

Where is the controller.js - or something like it?

I am building the maptraq2 - built in ionic 1 .

I have two issues -

  1. I need to expand text areas based on the volume or size of text.
  2. I have a side menu and I need to use a range - currently the side menu stops the range from sliding.

Both of these have work arounds that require I access the controllers, but I can't find a controller.js in the source - or the js that performs the same function. I need to add this code to it, but I need to know where it should go.

For number 1.
angular.module('app').directive('expandingTextarea', function () {
return {
restrict: 'A',
controller: function ($scope, $element, $attrs, $timeout) {
$element.css('min-height', '0');
$element.css('resize', 'none');
$element.css('overflow-y', 'hidden');
setHeight(0);
$timeout(setHeightToScrollHeight);

Code: Select all

        function setHeight(height) {
            $element.css('height', height + 'px');
            $element.css('max-height', height + 'px');
        }

        function setHeightToScrollHeight() {
            setHeight(0);
            var scrollHeight = angular.element($element)[0]
              .scrollHeight;
            if (scrollHeight !== undefined) {
                setHeight(scrollHeight);
            }
        }

        $scope.$watch(function () {
            return angular.element($element)[0].value;
        }, setHeightToScrollHeight);
    }
};

});

For number 2:
(function() {"use strict";

Code: Select all

angular
    .module('MyApp.Directives.range', [])
    .directive('range', rangeDirective);

function rangeDirective() {
return {
restrict: 'C',
link: function (scope, element, attr) {
element.bind('touchstart mousedown', function(event) {
event.stopPropagation();
event.stopImmediatePropagation();
});
}
};
}
})();

Return to “Issues”