Thursday, 15 May 2014

javascript - AngularJS : controller fails when minified -



javascript - AngularJS : controller fails when minified -

this question has reply here:

angularjs : minification issue in directive 2 answers

this controller throws unknown provider, understand need prepare controller prevent minified , dependency injection problems. not working. simplyfied show how using dependencies.

adminapp.directive('cashflower', ['$compile', '$timeout', '$http', 'global', function ($compile, $timeout, $http, global) { var cashflow = function (init) { this.curr = init.curr; // more }; homecoming { restrict: 'e', replace: true, templateurl: '/appadmin/templates/cashflower.html', controller: function ($scope) { $scope.decimalp = global.regexp.decimalp; $scope.$watch('total', function () { calculateremaining(); }); $scope.toggleiscurrlocked = function () { $scope.iscurrlocked = !$scope.iscurrlocked; if (!$scope.iscurrlocked) { $timeout(function () { $scope.iscurrlocked = true; }, 20000); } }; $scope.placement = $scope.placement ? $scope.placement : 'bottom'; $scope.failed = false; }, link: function (scope, element) { var goforit = function () { $http({ method: 'get', url: '/appadmin/templates/cashflowerpopover.html' }). success(function (data) { element.popover({ html: true, placement: scope.placement ? scope.placement : 'bottom', content: $compile(data)(scope) }); scope.failed = false; }) .error(function () { scope.failed = true; }); }; goforit(); angular.element(element).click(function () { if (scope.failed) { goforit(); } }); }, scope: { somescope: '=' } }; }]);

controllers directives dependency injected else. alter utilize array syntax , golden:

controller: ['$scope', function($scope){ //controller impl }]

javascript angularjs minify

No comments:

Post a Comment