AngularJS具有唯一的字符串?

时间:2018-12-07 17:37:51

标签: angularjs

{
"tab": {
"test": {
"publisher": {
"app": "tab",
"stream": "test",
"clientId": "5FOFK4JE",
"connectCreated": "2018-12-07T16:44:06.357Z",
"bytes": 1154224768,
"ip": "33.333.33.33",
"audio": {
"codec": "AAC",
"profile": "LC",
"samplerate": 44100,
"channels": 2
},
"video": {
"codec": "H264",
"width": 1920,
"height": 1080,
"profile": "Main",
"level": 4.2,
"fps": 60
}
},
"subscribers": []
}
},
"tab2": {
"test2": {
"publisher": {
"app": "tab2",
"stream": "test2",
"clientId": "P8FVV1JY",
"connectCreated": "2018-12-07T17:28:12.874Z",
"bytes": 1192755,
"ip": "33.333.33.333",
"audio": {
"codec": "AAC",
"profile": "LC",
"samplerate": 44100,
"channels": 2
},
"video": {
"codec": "H264",
"width": 1920,
"height": 1080,
"profile": "Main",
"level": 4.2,
"fps": 60
}
},
"subscribers": []
}
}
}

我试图在每个内部调用Publisher.app,但问题是tab,test和tab2,test2都是唯一的。我将如何调用发布者应用程序。我还计划使用其他数据,但首先想了解这一点。这是我正在处理的代码:

<!DOCTYPE html>
<html ng-app="App">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.js"></script>
<script src='http://ajax.googleapis.com/ajax/libs/angularjs/1.6.6/angular-resource.js'></script>
<script>
var app = angular.module('App', []); 
app.controller('serverCtrl', function($scope, $http, $interval) {
    $http.get("https://somewebsite.com/api/streams")
	.then(function(response) {$scope.data = response.data;});
    this.interval = $interval(function() {
        $http.get("https://somewebsite.com/api/streams")
	    .then(function(response) {$scope.data = response.data;});
    }, 5000);
});

</script>
</head>
<body>

        <div ng-controller='serverCtrl'>
<pre>{{ data }}</pre>
</div>
    </body>
</html>
如果有人能证明这是如何完成的,我将不胜感激,我是学习角度js的新手,因此感谢所有帮助。如果您可以更改代码并解释更改的各个部分的工作方式,我将更加感激。

0 个答案:

没有答案