0

I have 1 different component layout loaded by directive at bigger and smaller screen.

Is it possible to do that at AngularJS?

Have read the doc from here and here but no luck

2 Answers 2

2

You can get screen size in Angular with:

$scope.windowWidth = $window.innerWidth;

Based on this line, just ng-if or ng-show your div:

<div directive1 ng-if="windowWidth < 768">
    Directive1 on small screens
</div>

<div directive2 ng-if="windowWidth >= 768">
    Directive2 on large screens
</div>
Sign up to request clarification or add additional context in comments.

1 Comment

Yes I just did that and it works now.. Will accept your answer!
0

You can use the $window.innerWidth property inside your directive and manipulate your template accordingly.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.