I am getting strange errors with minification, I suspect it has something to do with the fact i have a controller within the directive:
var app = angular.module('myapp');
app.directive("person", ['$dialog', function($dialog) {
return {
restrict: "E",
templateUrl: "person/views/person.html",
replace: true,
scope: {
myPerson: '='
},
controller: mycontroller
};
function mycontroller($scope, $attrs) {
$scope.variable = 1;
}
}]);
What is the proper way to refactor this so it doesn't get broken during minifaction?
angular.module('myApp').controller('mycontroller', ['$scope', '$attrs',mycontroller]);Avoid using global controllers, register them using controller constructor function and just do the explicit dependency annotation just like what you are doing with the directive.controller:'mycontroller'or just use inline array @ your controller key's value itself ex:-controller: ['$scope', '$attrs', mycontroller].