var init = function(){
$scope.getAllFriends($rootScope.rootName)
.then(function(data) {
console.log(data);
}, function(err) {
//error
});
}
init();
$scope.getAllFriends = function(name){
return friendService.getAllfriends(name)
}
anglejsに新しいですが、ページの読み込み時に関数を呼び出そうとしていますが、エラーが発生しています。誰でも私が間違っている場所を修正することができます。AngularJS:ページの読み込み時に関数を呼び出す方法
はTypeError:$ scope.getAllFriendsあなたはまだ関数を呼び出すしようとしている機能
あなたはNG-INIT = "は、init()" htmlタグの角度ディレクティブを使用することができます(https://docs.angularjs.org/api/ng/directive/ngInit)[参照] –
ショー:このようにさらに援助のためのあなたのHTMLコード – AranS