참조 : http://stackoverflow.com/questions/27315796/getting-rootscopeinprog-error-when-calling-click-method-of-input-type-file-pro


In angular at any point in time, there can be only one $digest or $apply operation in progress.


$timeout.를 이용하여 해결 할 수가 있다.


설정

트랙백

댓글

반응형으로 만드려다보니 css와 javascript 부분이 변환해야할 경우가 생긴다.

AngularJS를 쓸 경우에는 이런 식으로 코드를 짜도 되고, 자바스크립트로만 할 경우, 밑 코드만 봐도 javascipt로 변환하는 건 어렵지 않을꺼 같다.


참조 : https://github.com/paul-hammant/angular_instead_of_media_queries

 function ResponsiveDemoCtrl($scope, $window) {
    $scope.oneColumn = false;
    $scope.width = 0;
    $scope.height = 0;
    $scope.leftMarginStyle = {};
    $scope.rightMarginStyle = {};
    $scope.middleStyle = {};

    $scope.updateWidth = function() {
        $scope.width = $window.innerWidth;
    }

    $scope.updateHeight = function() {
       $scope.height = $window.innerHeight;
    }
    
    $scope.columnAdjustments = function() {
        if ($scope.width < 768) {
            $scope.oneColumn = true;
            var mid = $scope.width - 30;
            $scope.leftMarginStyle = { width: '15px', maxWidth: '15px' };
            $scope.middleStyle = { width: mid + 'px', maxWidth: mid + 'px', };
            $scope.rightMarginStyle = { width: '15px', maxWidth: '15px', verticalAlign: 'text-top' };
        } else if ($scope.width >= 1024 ){
            $scope.oneColumn = false;
            var mid = 614;
            var margin = ($scope.width - 614) * 0.5;
            $scope.leftMarginStyle = { width:  margin + 'px' };
            $scope.middleStyle = { width: mid + 'px', maxWidth: mid + 'px', };
            $scope.rightMarginStyle = { width: margin + 'px', verticalAlign: 'text-top' };
        } else {
            $scope.oneColumn = false;
            var pc20 = Math.round($scope.width * 0.2);
            var pc60 = Math.round($scope.width * 0.6)
            $scope.leftMarginStyle = { width:  pc20 + 'px' };    
            $scope.middleStyle = { width: pc60 + 'px', maxWidth: pc60 + 'px', };    
            $scope.rightMarginStyle = { width: pc20 + 'px', verticalAlign: 'text-top' };    
        }
    }    
    
    $scope.updateWidth();
    $scope.updateHeight();
    $scope.columnAdjustments();

    $window.onresize = function () {
        $scope.updateWidth();
        $scope.updateHeight();
        $scope.columnAdjustments();
        $scope.$apply();
    }
  }

설정

트랙백

댓글

<body ng-controller="MainCtrl" ng-init="init()">
 
<div ng-init="init('Blah')">{{ testInput }}</div>
</body>

app.controller('MainCtrl', ['$scope', function ($scope) {
  $scope.testInput = null;
  $scope.init = function(value) {
    $scope.testInput= value;
  }
}]);

Here's an example.

 

ng-init가 잘 작동되지 않으면 이렇게 해보는 게 좋을 듯하다.

아님 이렇게 초기화 값을 init에 집어넣는 것도 괜찮은 듯

 

http://stackoverflow.com/questions/19981627/setting-scope-property-with-ng-init-doesnt-work

 

설정

트랙백

댓글

I had a similar need and had the same problem accessing the scope using angular.element. I was was able to solve it as follows though:

In your main/parent controller do something like this:

$scope.food = 'Mac & Cheese';
window.$windowScope = $scope;
$window.open('views/anotherWindow.html', '_blank','menubar=yes,toolbar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes,personalbar=yes');

Then in the child window controller you can access $windowScope like this:

$scope.parentWindow = window.opener.$windowScope;
console.log($scope.parentWindow.food);

An alternative to putting data directly into the scope would be to use $window scope to broadcast and/or emit events, which is the preferred way of cross-controller communication in angular.

 

 

http://stackoverflow.com/questions/17007939/accessing-parent-window-angular-scope-from-child-window

설정

트랙백

댓글