问题描述
我使用的 NG-IMG作物在角。通过安装后亭子安装--save ngImgCrop和注射时,我被咕噜命令来运行它的依赖,我得到了一个错误:
I am using ng-img-crop in angular. After installing it by "bower install --save ngImgCrop" and injecting the dependency when I run it by grunt command, I got an error:
Uncaught Error: [$injector:modulerr] Failed to instantiate module mean due to:
Error: [$injector:modulerr] Failed to instantiate module ngImgCrop due to:
Error: [$injector:nomod] Module 'ngImgCrop' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
我也跟着通过在
在code是如下:
I followed through the steps mentioned at https://www.npmjs.com/package/ng-img-cropthe code is as follows:
home.client.view.html:
home.client.view.html:
<script src="public\lib\ngImgCrop\source\js\ng-img-crop.js"></script>
<link rel="stylesheet" type="text/css" href="public\lib\ngImgCrop\source\scss\ng-img-crop.css">
<style>
.cropArea {
background: #E4E4E4;
overflow: hidden;
width:500px;
height:350px;
}
</style>
<body ng-app="core" ng-controller="Ctrl">
<div>Select an image file: <input type="file" id="fileInput" /></div>
<div class="cropArea">
<img-crop image="myImage" result-image="myCroppedImage"></img-crop>
</div>
<div>Cropped Image:</div>
<div><img src="myCroppedImage" /></div>
</body>
home.client.controller.js
home.client.controller.js
angular.module('core', ['ngImgCrop'])
.controller('Ctrl', function($scope) {
$scope.myImage='';
$scope.myCroppedImage='';
var handleFileSelect=function(evt) {
var file=evt.currentTarget.files[0];
var reader = new FileReader();
reader.onload = function (evt) {
$scope.$apply(function($scope){
$scope.myImage=evt.target.result;
});
};
reader.readAsDataURL(file);
};
angular.element(document.querySelector('#fileInput')).on('change',handleFileSelect);
});
请帮我在这。
谢谢
Please help me in this.Thanks
推荐答案
我觉得你应该使用的JS在编译文件夹文件,而不是源文件夹
I think you should be using the the js file in the compile folder rather than the source folder
即公共/ lib中/ ngImgCrop / 编译 /unminified/ng-img-crop.js
ie public/lib/ngImgCrop/compile/unminified/ng-img-crop.js
这篇关于ngImgCrop依赖注入不AngularJs正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!