如何使用onclick()更改json数据?

时间:2016-04-05 06:46:00

标签: angularjs json

这是一个angularjs app.Here我有2个json文件malayalam.js和english.js。当我打开应用程序时,我想看到应用程序及其数据来自malayalam.js(默认)。当我点击index.html中的onclick()时,我想将内容更改为english.js

app.js

$scope.templeMl = 'js/malayalam.js';
$scope.templeEn= 'js/english.js';


 $scope.loadlanguage= function (file) {
        $http.get(file)
        .then(function (result) {
            $scope.result=result;
            console.log($scope.result.data.root);



        })
     }

 $scope.loadLanguages=function(files){
 if(files==english){
$scope.loadlanguage($scope.templeEn);
}
else
{
$scope.loadlanguage($scope.templeml);
}
}

的index.html

<button class="button button-icon" ng-click="loadLanguages(english)">
            en
</button>

0 个答案:

没有答案