我在javascript中的普通类中有一个jquery类.是否可以从jquery类中的回调函数访问父类范围内的变量?
我的意思的一个简单示例如下所示
var simpleClass = function () {
this.status = "pending";
this.target = jqueryObject;
this.updateStatus = function() {
this.target.fadeOut("fast",function () {
this.status = "complete"; //this needs to update the parent class
});
};
};
Run Code Online (Sandbox Code Playgroud)
现在在上面的示例中,回调函数尝试访问jquery对象的范围.有没有办法访问父类中的状态变量?
我目前正在构建一个可以更改主题的应用程序.在这个例子中,一个主题只包括改变应用程序中几个关键元素的颜色.
所以目前,在所有需要主题颜色的元素上,我给了他们css类has-main-color.
在控制器中,我从Web服务获取所需的颜色并将其设置为范围$scope.mainColor = color;.
所有这一切都很好,但我遇到的问题是我找不到一种合适的方法将这种颜色应用到has-main-color课堂上.
目前,我正在尝试以下方法:
<style>
.has-main-color {
color: {{mainColor}}
}
</style>
Run Code Online (Sandbox Code Playgroud)
你可能猜到,这不是很好.
那么使用AngularJS解决这个问题的最佳方法是什么?
因此,我试图让 AWS Amplify 的数据存储库与我正在构建的 ReactJS Web 应用程序一起使用。我手动使用 graphql 突变向 api 发送数据并从 api 发送数据,然后我尝试按照本教程设置 DataStore 。在具有索引数据库的客户端中,一切工作正常,但我无法使数据与 api 同步。我在控制台中收到以下错误:
DataStore - Data won't be synchronized. No GraphQL endpoint configured. Did you forget `Amplify.configure(awsconfig)`?
Run Code Online (Sandbox Code Playgroud)
我仔细检查了一遍,我肯定将我的 AWS 导出包括在内:
import Amplify from "@aws-amplify/core";
import awsExports from "./aws-exports";
Amplify.configure(awsExports);
Run Code Online (Sandbox Code Playgroud)
生成的内容./aws-exports.js如下:
/* eslint-disable */
// WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.
const awsmobile = {
"aws_project_region": "us-east-2",
"aws_appsync_graphqlEndpoint": "https://xxxxxxxxxxxxxx.appsync-api.us-east-2.amazonaws.com/graphql",
"aws_appsync_region": "us-east-2",
"aws_appsync_authenticationType": "API_KEY", …Run Code Online (Sandbox Code Playgroud) 运行时可以控制自动修复哪些规则tslint --fix吗?理想情况下,我只想自动修复空白和引号规则,然后我将手动评估其余部分。我似乎在文档中找不到任何内容可以告诉我哪些规则可以自动修复,或者如何控制要应用的规则,并且我对盲目地修复所有内容有些担心。
我目前正在使用Angular CLI自动生成的tslint文件。
angular ×1
angularjs ×1
aws-amplify ×1
class ×1
css ×1
javascript ×1
jquery ×1
parent ×1
reactjs ×1
scope ×1
tslint ×1
typescript ×1