Javascript 使用角度指令移动图像

Javascript 使用角度指令移动图像,javascript,jquery,angularjs,angularjs-directive,Javascript,Jquery,Angularjs,Angularjs Directive,当屏幕变小时,我想在两个div图像之间移动,使用角度指令。 使用以下指令,当屏幕变小/变高时,我可以更改一行的内容。但是我不能用这个图像。我想把那个图像从“之前”的div移到“然后”的div。我该怎么办? 链接到代码: 指令代码: var app = angular.module('plunker', []); app.controller('MainCtrl', function($scope) { $scope.name = 'World'; }); app.directive('bro

当屏幕变小时,我想在两个div图像之间移动,使用角度指令。 使用以下指令,当屏幕变小/变高时,我可以更改一行的内容。但是我不能用这个图像。我想把那个图像从“之前”的div移到“然后”的div。我该怎么办? 链接到代码:

指令代码:

var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
});

app.directive('browseContent', function($window) {
return {
    restrict: 'E',
    template: '<div ng-include="templateUrl"></div>',
    link: function(scope) {

        $window.onresize = function() {
            changeTemplate();
            scope.$apply();
        };
        changeTemplate();

        function changeTemplate() {
            var screenWidth = $window.innerWidth;
            if (screenWidth < 768) {
                scope.templateUrl = 'browse-content-mobile.html';
            } else if (screenWidth >= 768) {
                scope.templateUrl = 'browse-content.html';
            }
        }
    }
}
});
var-app=angular.module('plunker',[]);
应用程序控制器('MainCtrl',函数($scope){
$scope.name='World';
});
应用程序指令('browseContent',函数($window){
返回{
限制:'E',
模板:“”,
链接:功能(范围){
$window.onresize=function(){
changemplate();
作用域:$apply();
};
changemplate();
函数changemplate(){
var screenWidth=$window.innerWidth;
如果(屏幕宽度<768){
scope.templateUrl='browse content mobile.html';
}否则如果(屏幕宽度>=768){
scope.templateUrl='browse content.html';
}
}
}
}
});