Angularjs 2打字稿app permentaly移动

时间:2016-03-12 15:07:47

标签: javascript typescript angular

enter image description here

当我运行我的应用程序时,它给了我几个错误:

第一个是:

  

SyntaxError:class是类缩略图中的保留标识符

代码:

    <div align="right" class="log-in-checkout" id="left-nav">
                  <span class="login">
                        <a href="#" data-toggle="modal" data-target="#login-modal"><span class="hidden-xs text-uppercase">Sign-in</span></a> or <a href="customer-register.html"><span class="hidden-xs text-uppercase">Register</span></a>

                   </span>
                       <span class="checkout">
                           <a class="btn btn-shopping-cart" href="#"><i class="fa fa-shopping-cart fa-2x"></i></a>
                       </span>
    </div>

第二个错误是:

  

获取http://localhost:51580/app

     

301永久移动

角度的配置是:

const MAXHEIGHT = 170;
const MAXWIDTH = 320;
import {Subcategory} from './subcategory'
//import {Category} from './category'
import {bootstrap}    from 'angular2/platform/browser'

class Thumbnail {

    width: number;
    height: number;

    constructor(element: HTMLImageElement) {
        this.height = element.height;
        this.width = element.width;
    }

    resize(oImage: HTMLImageElement) {
        var maxWidth = 100; // Max width for the image
        var maxHeight = 100;    // Max height for the image
        var ratio = 0;  // Used for aspect ratio
        var width = oImage.width;    // Current image width
        var height = oImage.height;  // Current image height

        // Check if the current width is larger than the max
        if (oImage.width > MAXWIDTH) {
            ratio = MAXWIDTH / width;   // get ratio for scaling image
            oImage.width=MAXWIDTH; // Set new width
            oImage.height=height * ratio;  // Scale height based on ratio
            height = height * ratio;    // Reset height to match scaled image
            width = width * ratio;    // Reset width to match scaled image
        }

        // Check if current height is larger than max
        if (height > MAXHEIGHT) {
            ratio = MAXHEIGHT / height; // get ratio for scaling image
            oImage.height= MAXHEIGHT;   // Set new height
            oImage.width= width * ratio;    // Scale width based on ratio
            width = width * ratio;    // Reset width to match scaled image
            height = height * ratio;    // Reset height to match scaled image
        }
        // Check if current height is smaller than max
        if (height < MAXHEIGHT) {
            ratio = MAXHEIGHT / height; // get ratio for scaling image
            oImage.height = MAXHEIGHT;   // Set new height
            oImage.width = width * ratio;    // Scale width based on ratio
            width = width * ratio;    // Reset width to match scaled image
            height = height * ratio;    // Reset height to match scaled image
        }
        // Check if the current width is smaller than the max
        if (oImage.width < MAXWIDTH) {
            ratio = MAXWIDTH / width;   // get ratio for scaling image
            oImage.width = MAXWIDTH; // Set new width
            oImage.height = height * ratio;  // Scale height based on ratio
            height = height * ratio;    // Reset height to match scaled image
            width = width * ratio;    // Reset width to match scaled image
        }
        document.body.appendChild(oImage);
        console.log(oImage.height);
        console.log(oImage.width);

    }

}; 

window.onload = () => {
    var oImage = new Image();
    var oImage2 = new Image();
    // var category = new Category(1, "string");
    var subcategory = new Subcategory("teste",1,2);
    oImage.src = 'AngularJS.png';
    oImage.setAttribute('class','img-responsive');
    oImage2.src = 'ts.jpg';
    var thumbnail = new Thumbnail(oImage);
    var thumbnail2 = new Thumbnail(oImage2);
    thumbnail.resize(oImage);
    thumbnail2.resize(oImage2);
    console.log(oImage.height);
    console.log(oImage.width);
};

我已经尝试创建名为app的文件夹并移动该文件夹的文件,但错误仍然存​​在。我需要帮助,我失去了几个小时,无法解决任何问题。我附加一个文件结构的图像和另一个带有firebug错误的图像。提前谢谢。

1 个答案:

答案 0 :(得分:0)

正如@Eric在评论

中所建议的那样

Firefox版本不支持类&lt; 45根据this article 。而是在chrome中尝试相同的用例。

发布的回答可能对某人有帮助。