Ale.js

Static Data

Start

In the Data article, you have learned the Data property. If you haven’t studied yet, please learn Data first.

Detailed difference

The most important difference between Data and Static Data is that the view will not be refreshed when the static data is updated [Please enter app.staticData.i = "new value" in the console to see if the example below will Update it!]:

1
2
3
4
5
6
7
8
Ale("test", {
template: function(){
return "The value of data i on the view is:" + this.staticData.i;
},
staticData: {
i: "Hello"
}
})

Advanced

Similarly, static data also supports function types:

1
2
3
4
5
6
staticData: function(){
/* Need to use return */
return {
i: "Hello"
}
}

Found some errors? Edit on Github!